minorwork / minorwork
A minimal framework
Installs: 1 264
Dependents: 1
Suggesters: 0
Security: 0
Stars: 11
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- nikic/fast-route: ^1.2
Requires (Dev)
- phpunit/phpunit: ^4|^5|^6|^7
README
A minimal PHP framework that is serious on being minimal.
Features:
- A container.
- Named routing with redirection support
- Less than 300 lines.
- Only external dependency is
nikic/fast-route
for routing. - Optional Twig integration (minorwork-twig)
Install
You can install MinorWork with composer.
composer require minorwork/minorwork
PHP 5.4 or newer required.
Usage
Using MinorWork framework looks like this:
<?php // This is index.php // All traffic should bed handled by this file. // You may need edit your .htaccess for this. include __DIR__ . '/../vendor/autoload.php'; use MinorWork\App; $app = new App(); $app->setRouting([ 'root' => ['/', '\Controller\Index:home'], 'loginForm' => ['GET', '/login', '\Controller\Login:form'], 'loginAction' => ['POST', '/login', '\Controller\Login:login'], 'article' => ['/articles/{id}', '\Controller\Article:show'], 'users' => ['\Controller\User:list'], // matches /users 'userProfile' => ['/user/{id}', '\Controller\User:profile'], ]); $app->run();
Define routing, the run the app. MinorWork will take care the rest.
Another example is in example/ folder. You can see it in action using PHP dev server.
cd example
php -S localhost:8765
Read the documentation for more detail.