jhonoryza / bandung-framework
small php framework
Requires
- php: ^8.2
- larapack/dd: ^1.1
- laravel/prompts: ^0.1.15
Requires (Dev)
- illuminate/testing: ^10.0
- phpstan/phpstan: 1.10
- phpunit/phpunit: ^10.2
This package is auto-updated.
Last update: 2024-12-17 05:58:04 UTC
README
Bandung Framework
small php framework
Framework Directory
app
directory is playground for the frameworksrc
directory is the core of the frameworkpublic
directoryindex.php
will be called when serve web requestbandung
file will be called when running console commandtests
directory is where the test of the framework reside
Feature
- route
- request
- response
- console command
WIP
- query builder
- migration
- queue
- filesystem
- notification
- event and listener
Getting Started
create empty project
mkdir myapp
cd myapp
composer init
installation
composer require jhonoryza/bandung-framework
cp vendor/jhonoryza/bandung-framework/bandung .
php bandung install
after installation completed there will be several files in your project
app/
directory, use this folder to put class controller and command, the framework will scan this folderpublic/index.php
this is the entry point for your web applicationbandung
this is the entry point for your console command
create a simple endpoint
in app directory you can create a class lets say HomeController
and
let's create a route /
, /posts
and /posts/{id}
#[Get(uri: '/')] public function index(): ResponseInterface { return Response::make(HttpHeader::HTTP_200, 'Hello world!'); } #[Get(uri: '/posts')] public function posts(): ResponseInterface { return JsonResponse::make(HttpHeader::HTTP_200, [ 'message' => 'ok' ]); } #[Get(uri: '/posts/{id}')] public function postDetail(string $id): ResponseInterface { return JsonResponse::make(HttpHeader::HTTP_200, [ 'message' => 'ok', 'id' => $id ]); }
the Attributes #[Get('/')]
will mark this function as a route /
let's run php bandung serve
and open http://127.0.0.1:8000
get environment variables
$appName = getenv('APP_NAME'); echo $appName;
console command
you can run like this php bandung
this will print all available commands
let's create a custom command
in app directory you can create a class lets say CommandClass
and
let's create a function testWarning
#[Command('test:warning')] public function testWarning(): void { warning('testing warning ok'); }
the Attributes #[Command('test:warning')]
will mark this function as command with name test:warning
you can call it from terminal : php bandung test:warning
Test
./vendor/bin/phpunit
Security
If you've found a bug regarding security please mail jardik.oryza@gmail.com instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.