Update April 10th 2016: A lot of this information is now contained in the updated repository.

There are a lot of large frameworks for PHP out there that will do everything you could ever imagine. But what if you don’t need all of that extra power and complexity?

Composer to the rescue

I first started by looking at the dependencies of hugely popular PHP frameworks like Laravel and SlimFramework. Doing this, I was able to narrow down the components I would need to five beautiful, self contained components:

FastRoute, for lightweight and speedy routing

HttpFoundation, for simplifying Response/Request handling

Container (thephpleague), for dependency injection

Whoops, for beautiful error handling

phpdotenv, for keeping your secrets

These components, combined with a little bit of glue, make for a dead simple diy micro-framework that just works.

Check it out

Frameworkless is available on GitHub as public domain.

Simply clone the repository, cd, and finally execute “vagrant run” (assuming you have vagrant installed). From there, navigate to http://localhost:8080, you should be greeted with “Hello there!”. Using your favorite RESTful client, try out the /todos endpoint, a simple todo manager backed by MySQL.

The installer script takes care of installing nginx, hhvm, mysql, composer, and even seeding the database.

Conclusion

I hope this brief introduction has helped you see how incredibly simple setting up your own “framework” with composer can be. This mini project was heavily inspired by Patrick Louys’s no-framework-tutorial, which I highly recommend you read.