Mechanic is a lightweight and flexible PHP microframework created for study purposes. It has been designed to provide developers with a profound learning experience on how PHP frameworks work and to assist them in understanding the fundamental concepts behind routing, middleware, and HTTP request handling.
Some of Mechanic's components are inspired by those of Symfony and Laravel.
use Pietroagazzi\Mechanic\Http\{JsonResponse,Response};
use Pietroagazzi\Mechanic\Mechanic;
$app = new Mechanic;
$app->get('/', function () {
return new Response('Hello World!');
});
$app->get('/users', function () {
return new JsonResponse([
'users' => [
'Pietro',
'Mario',
'Luigi'
]
]);
});
$app->handle();
docker-compose up -d
# show logs
docker-compose logs -f
# stop containers
docker-compose down
🚀 Then visit http://localhost:36000/
# install dependencies
composer install
php -S localhost:8080 -t public
🚀 Then visit http://localhost:8080/