Skip to content

pietroagazzi/mechanic

Repository files navigation

Mechanic

Makefile CI codecov

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();

Run it

Using Docker 🐳

docker-compose up -d

# show logs
docker-compose logs -f

# stop containers
docker-compose down

⚠️ The first time you run the command, it will take a while to download the images and build the containers.

🚀 Then visit http://localhost:36000/

Using PHP built-in server 🐘

# install dependencies
composer install

php -S localhost:8080 -t public

🚀 Then visit http://localhost:8080/

About

Mechanic is a PHP micro framework created for study purposes.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published