itsimiro / lavi
Lavi framework
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^7.4.2
- itsimiro/lavi-router: ^1.0
- symfony/http-foundation: v5.4.6
Requires (Dev)
- phpunit/phpunit: ^9.5.20
This package is not auto-updated.
Last update: 2024-11-02 05:05:44 UTC
README
Install
composer require itsimiro/lavi
DI Container is a required dependency. Install any package that implements ContainerInterface.
Routes
The framework router currently supports GET and POST requests.
You can specify the namespace explicitly in the controller name.
$router = new \Lavi\Router\Router();
$router->get('/', [
'controller' => 'MyNamespace\HomeController',
'action' => 'index'
]);
It is also possible to declare it.
$router->post('/users/', [
'namespace' => 'MyNamespace',
'controller' => 'UserController',
'action' => 'add'
]);
Middlewares
You can use middlewares for routes. Execution occurs one at a time.
$router->get('/me/', [
'namespace' => 'App\\Controllers',
'controller' => 'UserController',
'action' => 'retrieve',
'middlewares' => [\App\Middlewares\AuthMiddleware::class]
]);
Request
It is possible to use different requests, by default we use Symfony Request.
If you want to use your own request class, then it must implement the IRequest
interface.
Controllers
The controllers are located in the src/controllers
folder,
but you can store them wherever convenient for you.
Events Controller (in progress)
There are 2 events that you can subscribe to in the controller.
- before();
- after();
Methods that must be subscribed to these events must begin with the prefix do
.
Tests
Tests run on the PHPUnit library.
Tests are in the tests folder.
Run tests:
composer test