To develop a REST API in PHP quickly and easily it’s a good idea to use a lightweight PHP Framework. Developing your own from scratch with plain PHP, apart from being a pain and taking too much time, is likely to require a lot of testing and deviate from REST standards. Ankur Kumar over at Find Nerd takes you through the top five PHP frameworks to make your life easier when creating a REST API.
First up, is Slim. This PHP microframework has a scalable, modular architecture that lets you use exactly what you need and nothing more. Even better, you can put your entire Web Service in a single PHP file. Features include: the ability to enable and disable debugging for the API, the ability to inspect and manipulate HTTP messages including headers and cookies, and support for dependency injection. A big plus is that its HTTP Router maps route callbacks to target HTTP request methods and URIs.
Next in line is Silex. It’s a microframework based on Symfony. It comes in two flavors. The fat version includes Symfony components and a template engine. The slim version just has a basic routing engine and some procedures to work with other libraries. The slim version is what you want if you’re keeping it lightweight. It’s fast and has features like one step controllers and easy-to-manage testing tools.
Third in line is Wave. It’s a popular PHP microframework based on the MVC design pattern. It comes with a view controller and special gateway for web functionality. It doesn’t, however, come with any optional libraries so it’s extremely lightweight and built for speed.
Next up is Limonade. Like Wave, it’s lightweight and easy to use. Ankur advises its use for prototyping and rapid web development. It’s not suited to larger projects mainly because it’s functionality is limited and it can’t be easily integrated with other libraries or extended. On the plus side, it’s easy to learn.
Last but not least is Lumen. It’s a Laravel-based microframework that’s recommended for Microservice architectures because of its blazing speed. Not surprisingly, it’s best used with Laravel, since its code can be easily be dropped into a Laravel app. Out-of-the-box features include caching, validation and routing.