A PHP Framework in simple terms is a platform used by developers to create web applications – obviously made by PHP. They help developers concentrate on their applications – the bigger picture – instead of some small details like creating a database connection. Instead you can concentrate on how best to query your data. They make it easier to develop PHP applications rapidly and take care of thing like security and enforce coding standards or style of coding. Frameworks tend to be bloated with many libraries a developer may never use.
A good example for this are databases. There are so many databases you can use with your application such as MySQL, MSSQL, Oracle etc. A PHP framework will have libraries and ability to connect to all this database and if you are just using one, then you don’t need the rest of the database libraries. And that’s why we have microframeworks.
A microframework is a framework in its own light but with barebone libraries and functionality with modular support – they are skeletons of frameworks. A microframework only has the libraries you need to get started and then you can add modules for what you need to do. Microframeworks have a small code footprint. It also improves their performance.
When to use Frameworks?
The world is large enough for both Frameworks and Microframeworks. The thing is, you need to know when to use a framework and when to use a microframework. Frameworks can be used on projects of all kinds, especially when you are on tight deadline. Frameworks are good for building large PHP application that will utilize the large number of libraries that come with them.
When to use Microframeworks
Unlike frameworks, Microframeworks are not for every web application. They are suitable to small PHP applications like REST APIs. These applications perform specific functions and hence require just a few libraries which leads to a small footprint. They also provide developers with the freedom of choosing their own libraries to achieve what they want.
You can still use a microframework instead of a framework and vice versa but I would not recommend it. This is because if you were to use a microframework in place of a framework, you would end up adding a lot of libraries found in frameworks and hence end up with a framework. On the other hand, if you used a framework in place of a microframework, you would have a lot of libraries that are unnecessary. This would affect the performance of your application negatively.
When it comes to choosing a framework or microframework or even whether to use a framework, personal preferences come into play. But if you were looking for some guide on which framework to use, please read the following detailed analysis.
On a personal note though, I would recommend Laravel or Symphony for a framework and Slim or Lumen for a microframework. Lumen is microframework from Laravel and hence if you are already acquainted with Laravel, then Lumen is the obvious choice.