I have been using Slim 3 in some recent projects and wanted to create a quick boilerplate for scaffolding out RESTful APIs. Slim is a PHP microframework that helps you quickly write simple yet powerful web applications and APIs. It provides framework essentials such as routing, middleware, and dependency injection without all the bloat other “kitchen-sink” frameworks provide. My boilerplate comes with the following configurations out of the box:
Slim 3 Framework
Built on the latest Slim v3.10 PHP microframework and supports PSR-7 interface.
Eloquent ORM
Boilerplate is bundled with Laravel’s Eloquent ORM, a popular object-relational mapping library for PHP. This allows for easier query building and management of database data using object-orientated models.
JSON Web Tokens (JWT)
JWT middleware is bundled and used for user authentication sessions and to guard protected routes.
Respect\Validation
Respect\Validation helps saves time by allowing us to write less boring validation code for user-inputted data.
Monolog
Monolog provides out-of-the-box PSR-3 interface application logging.
PHPUnit
PHPUnit also comes bundled and I’ve written enough test scripts to provide 100% code coverage of example To-Do List API.
Phinx
Phinx makes database migrations a breeze, allowing you to write migrations in both PHP and SQL, while providing easy version management of your database.
To-Do List API
A RESTful user-authenticated To-Do List API ships with the boilerplate as quick example. See API documentation on GitHub.
Find it on GitHub
Get all the code and see the documentation on GitHub: https://github.com/crankedapps/slim-rest-boilerplate