PHP Micro-framework vs. Full-stack Framework
The differences between micro-frameworks and full-stack frameworks in PHP, and what you should focus on.
Join the DZone community and get the full member experience.Join For Free
Think back to the hazy days of early web-page development on the Internet. You saw many pages hand-coded in HTML — dynamic pages that could produce and display different content to customize a visitor’s experience were just a dream in a programmer’s eye. Then the first server development environments like WebBase began to emerge. “PHP,” — the “hypertext preprocessor” script — ColdFusion and Microsoft’s “ASP” programming tools came out to help create dynamic, modular websites. Full-stack frameworks finally appeared on the horizon, providing multiple libraries in one package. Popular web-application framework environments went on to include web2py, Ruby on Rails, Django, and ASP.NET.
The Rise of Micro-frameworks
Over time, full-stack frameworks grew ever bigger to handle the increasingly large and complex websites appearing across the online world. The downside of this growth is they became too difficult to develop simple projects, and you had too much overhead for rapid development.
In response to these challenges, engineers developed micro-frameworks. For smaller projects and specific-use cases, these stripped-down frameworks were easier to implement and provided faster testing and deployment.
Today you have a wide variety of full-stack and micro-PHP environments to choose from. Let’s take a closer look at the advantages and disadvantages of each one while examining some of the most successful packages.
PHP Micro-Framework vs. Full-Stack Framework
Full-stack frameworks assist programmers with the entire development stack from interfacing with the user to the data store. Anything outside of a full-stack framework is technically a “nonfull-stack framework.” Of that group, if the framework and libraries are smaller than “5k,” or 5,000 lines of code, it is known as a micro-framework.
Micro-frameworks leave out many of the components of a full-stack setup, including:
Web template engine
Roles, accounts, and authentication
Full-stack frameworks are like driving a huge, fully-equipped SUV compared to a stick-shift sports car. The full-stack framework has a plethora of features and options, but it can be cumbersome and slow. While micro-frameworks have fewer features, they also carry the advantages of being light, quick and nimble.
Full-stack frameworks function against themselves in that they can do many things — with the result that they do few things well. Micro-frameworks do fewer things well, but you may need to use multiple frameworks, and they do not always get along well.
When To Deploy Micro-Frameworks or Full-Stack Frameworks
If you have a small project and need specific features quickly, a micro-framework may be your best bet. For medium to large projects with more demands, a full-stack framework will work better.
Full-stack frameworks have everything you need. However, the way they do things and how they structure projects is not very flexible. Micro-frameworks have more flexibility and leave more decisions up to you.
However, one of the misconceptions about micro-frameworks is that they are only for small projects. It simply means that the framework does not have all of the components you’ll find in a full-stack environment. Micro-frameworks do not have all of the helpers, libraries and structures of the full-stack frameworks, but sometimes it is easier to focus on a specific challenge without worrying about which libraries you need.
A disadvantage of micro-frameworks is that when projects grow much bigger, the micro-framework may not have the features required to accommodate that growth. On the other hand, you get lots of flexibility.
For example, if you use a full-stack library in the beginning with the anticipation that the project will grow, you are still “married” to the libraries the full-stack framework provides, and they will not always be the best options for the project. An ideal middle ground might be to create the project out of one micro-framework in the beginning. Then you can split that framework and add additional ones as the project evolves.
PHP Full-stack and Micro-framework Examples
With almost 80 percent of servers on the Internet using PHP code in some capacity, PHP frameworks are popular and useful tools. Here the top five PHP full-stack and micro-frameworks in use today:
Here Are Five Great Full-stack PHP Frameworks For You:
Laravel is one of the most popular PHP frameworks used today. It has a supportive community and an extensive ecosystem of tutorials and resources. A free, open-source framework, it has a powerful packaging system, various options for accessing databases and some useful utilities to deploy and maintain applications. Taylor Orwell developed it in 2011 to overcome weaknesses he saw in the CodeIgniter web application framework.
An open-source framework, CakePHP resembles Ruby on Rails, a popular web application framework. Developed back in April of 2005, it was a leading framework for many years. CakePHP has worked hard to stay updated, and companies using it include fashion brand Express, Hyundai, and BMW.
Zend Framework has been in existence for almost ten years. An open-source project, it is a favorite of multi-national companies such as Cisco and BBC. Many of the people behind Zend Framework were developers of PHP. While powerful, Zend Framework is hard to learn and has a confusing array of configuration options — over time the project grew more complicated with many layers of classes developers found difficult to grasp.
If you feel the “need for speed,” Phalcon is for you. Phalcon is different from other frameworks in that it is an extension written in C. This approach allows it to increase execution speed and decrease the use of resources.
Phalcon 2.0, released in April 2015, used the Zephir coding language — it is probably the fastest entry in our list. Released in 2012, Phalcon was originally the product of Andres Gutierrez and various colleagues searching for a different way of approaching traditional PHP web application frameworks. Phalcon is:
Simple to learn, so it is a good choice for experienced and beginner developers alike.
Feature-rich to develop a broad variety of web applications.
Popular among PHP developers.
Rapidly increasing in popularity since it debuted in 2012.
Symfony is a reliable choice for large-scale projects. Using Ruby on Rails, Spring, and Django as inspirations, Symfony uses a system of reusable components. Developed by Sensiolabs, Symfony first appeared on the scene in 2005. An open-source PHP framework, it utilizes large parts of other PHP projects including:
Swift Mailer, a library for emails.
PHPUnit, a framework for testing units.
Its components are in some of the most successful projects online, including content-management system Drupal and the Twig templating engine.
Here Are Five Micro-PHP Frameworks You Should Try:
The team behind Laravel developed Lumen. If you are familiar with Laravel, then Lumen provides an easy transition to micro-frameworks. Designed by Taylor Otwell in 2014, it allows you to use many Laravel components such as “middleware,” validation, caching and the Laravel service container.
Slim is one of the most popular PHP microframeworks — it has more than 960,000 installs and came in 15th in a SitePoint survey of the top PHP frameworks of 2015. It features a powerful router, simple request and response abstractions, plenty of helper methods for easier caching, and session support. Josh Lockhart designed Slim, and he is also the author of the popular books “Modern PHP” and “PHP the Right Way.”
Introduced in September of 2010, Fabien Potencier and Igor Wiedler created Silex, based on Symfony and the Twig template engine. Silex is extremely lightweight and lets you add features as needed. Originally built to handle small projects, you can extend it into a full “MVC,” or model-view-controller, framework by choosing between two versions:
Fat: Comes with all features, a template engine and database abstraction.
Slim: Only includes a routing engine.
Wave separates itself from the competition due to its application-programming interface, or “API,” handler functionality that comes integrated into the framework. Developed in 2012 by Kristo Vaher, an Estonian developer, Wave is very lean, offering only the most common features required. Also, it has extensive documentation that is helpful for new learners. It comes complete with a gateway for clean URLs and a view controller.
The micro-stack version of the full-stack Phalcon framework, it is one of the fastest-growing PHP micro-stacks for the same reasons that its big brother is making so many waves in the PHP community. The original Phalcon came out in 2005 from Columbian developer Andres Gutierrez, a 2012 TR35 winner. Micro-stack Phalcon is the fastest micro-framework available due to its implementation as an extension in C. However, Phalcon does not have much community support and lacks thorough third-party documentation.
Decision Time: Full-stack or Micro-stack?
As you can see, there are lots of choices in PHP frameworks. When is it appropriate to use one selection over the other? Micro-frameworks are better for smaller projects that require simplicity, low overhead, and rapid deployment.
On the other hand, large website projects with many moving parts demand the robust libraries and powerful components of a full-stack framework. If you are creating an enormous application like a social-media or large e-commerce website with a global footprint, you have to use the strength and depth of a full-stack framework.
Experienced developers can get away with beginning a project on micro-frameworks and then adding additional micro-frameworks when needed. It is an attractive option, but beginner and intermediate developers should avoid this path.
The definitive answer is, “It depends.” In addition to the requirements of the project, constraints of budget, time, server architecture and programmer familiarity with the framework all come into play. The best option is to test various packages and determine through experience which option is right for your project.
Published at DZone with permission of , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.