Full-Stack Framework or Microframework, Laravel or Lumen?
What is a microframework? Are there any benefits of using a microframework as opposed to a full-stack framework? What are some examples of when it's right to use a microframework instead of a full-stack framework for custom software development?
A web framework is a tool for solving common software development problems fast (read as “cost-effectively”). Web frameworks are divided into full-stack frameworks and microframeworks. In this article, we will show what the differences between them are.
WHAT IS A WEB FRAMEWORK?
There is no accepted definition of a “web-framework” meaningful for both developers and non-tech people. Someone says it is a skeleton of any modern web application, others – that it is an application without custom functionality, or even - it is architecture, plus an implementation, plus documentation etc.
Well, there are a lot of official websites of different web frameworks. How do their creators describe what is a web (server-side, PHP) framework?
- Symfony Framework is a "set of PHP Components. Symfony Components are a set of decoupled and reusable PHP libraries".
- The Joomla Framework is a "PHP framework (a collection of software libraries/packages)".
- Zend Framework is a "collection of professional PHP packages".
Based on those official definitions, we can say that web framework is a collection of libraries/packages for creating a web application.
The difference between library and framework? In recent years these two terms have been used as those synonymous. The easiest way to differentiate the two is:
- A library contains many pieces of functionality that you may pick and choose from i.e. using one piece of technology doesn't mean you're locked into the rest. This means freedom, however, you will have more work cut out for you.
- A framework however very much sets out how you will be working. It provides a workflow that for better or worse is hard to change. This means rapid development/prototyping, but if significant changes are made in the future it may be impossible (or very time consuming) to implement them.
What is beyond doubt is that web frameworks “allows developers to save time by re-using generic modules in order to focus on other areas”. As an example, a framework will keep the developer from having to spend 2 or 3 days creating an authentication form (which is not a specific task). The time that is saved can be dedicated to more specific components as well as to the corresponding unit tests; giving the solid, sustainable and high-quality code. Another example: when working in teams, things can get ugly when it comes to choosing options for libraries and tools. Usually, each member of the team will try to push her/his preferred options. Nevertheless, if the team is using a framework, it can simply use the default options and avoid discussions.
DIFFERENCES BETWEEN FULL-STACK AND MICRO WEB FRAMEWORKS
A full-stack framework is a framework that attempts to provide nearly everything — from web serving to database management right down to HTML generation — that a developer could possibly need to build an application. It likely includes components that may not be needed by the majority of applications, but having them available makes it easier to integrate new features.
A microframework is a framework that attempts to provide only the components that are absolutely necessary for a developer to build an application; or it may focus on providing the functionality of one particular area very efficiently. Microframeworks often tend to be better-suited for smaller applications or for applications with specific purposes for which the framework was designed. In the case of web application frameworks, a microframework may be specifically designed for building the so-called APIs for another service or application. Microframeworks often need to be extended with additional components in order to make them provide more functionality.
By the way, here is one more explanation about differences between frameworks and microframeworks, which was made by the creator of one of the microframeworks. The popular «microframework movement» took off in 2013 as an ideology. A microframework is a collection of bare necessities required to build a web application. Typically, a microframework facilitates receiving an HTTP request, routing the HTTP request to the appropriate controller, dispatching the controller, and returning an HTTP response. Some microframeworks take this a few steps forward and also provide additional tools to manipulate the HTTP response (HTTP caching, status updates, redirects, and so on) as well as a middleware implementation. Many developers are familiar with larger full-stack frameworks like Laravel or Symfony. These excellent frameworks have a larger codebase, more "kitchen-sink" functionality, but also require more time to learn them. For some projects, both Laravel and Symfony are great tools. For other projects that do not require additional features, microframeworks are a more appropriate tool for the job.
DIFFERENCES BETWEEN LARAVEL AND LUMEN
Lumen microframework is a lightweight version of Laravel full-stack framework. Lumen use the Laravel syntax and components, and can be 'upgrade' easily to Laravel.
Lumen is a more specialized (and stripped-down) framework designed for Microservices development and API development. So, some of the features in Laravel such as HTTP sessions, cookies, and templating are not needed and Lumen takes them away, keeping what's essential - routing, logging, caching, queues, validation, error handling and a couple of others.
As Taylor Otwell, the main creator and maintainer of the Laravel and Lumen frameworks, underlined in his interview: “Lumen opts for maximum speed. The actual Lumen framework repository is probably only a dozen files or so. The rest is made up of the Illuminate components. This allowed me to flesh out the features of the framework very quickly, though it did take me three or four iterations to find a solution that was really, really fast while still providing very powerful features”.
Taylor Otwell also talked about one more key difference: «The entire bootstrap process is also located basically in a single file, which is less configurable overall than full-stack Laravel, but for small microservices and APIs that are mainly interested in speed it's a good trade-off».
Additionally, Lumen uses a faster router than Laravel (FastRoute instead of Symfony’s) and many features are disabled by default in Lumen in comparison with Laravel, for example, Facades, Dotenv environment files, Eloquent and so on.
Being the best in a competitive market such as global outsource software development means providing the best technology solution to meet business needs while keeping in mind the limited resources (time and money) and quality requirements.
Which tool to use – a full-stack framework like Laravel or a microframework like Lumen – depends on software requirements and developer competence/experience. Top-notch developers teach: “Use microframework if you are comfortable with making all of your own architecture decisions and full-stack framework if not”. Since large web application can be built based on microservice architecture approach, this means that projects must not be just micro or small to use the microframework.