Core PHP vs PHP Framework: what should you use?
I am building Core PHP and PHP framework teams in India since 2012. Here my experience:
1) Small to medium-sized web applications: Use a PHP framework
Small to medium-sized web applications usually have some specific purpose like:
- comparing prices and showing the best price
- showing different products and letting users search them
- register for some service and letting users download the courses and products
- make a booking for rooms or cabs or similar
The number of users will be around 100 to 1000 per day in these applications.
These criteria will apply to around 90 percent of all web applications.
For them, you can use a PHP framework. I would suggest one of the following:
- Laravel: the most modern PHP framework. It was created in 2011 and has seen incredible adoption by web developers since then.
- Symfony: this is what you would call an enterprise-level web framework. It is mostly used by IT departments of medium and large-sized companies, who build small and medium-sized platforms for their customers or their other departments (marketing, sales, HR, accounting, etc.)
- Zend: is another enterprise-level framework, which is tried and tested for many years.
New projects are usually started with Laravel. But most projects from the past had been started in Symfony or Zend, so you will see many opportunities here as well.
There are other frameworks like CodeIgniter, CakePHP and YII. They are not used that much anymore. But still, there are web developers using those technologies.
2) Maximum flexibility or maximum customizability needed: Use Core PHP
Suppose you are building a web application, which you are planning to license to other companies. Like an ERP, CRM, Account Software, or similar. Then use Core PHP or pure PHP, as you had called it.
The reason for this is, that you want to build your application like you want it to be.
A figurative example: Compare it to a picture. You can draw from scratch what you need and build on top of that picture whatever you want. In a framework, some people and table and backgrounds would already be pre-defined, which would not help you, as your plan is not to draw the picture fast, but according to your wishes.
Especially if you are building new modules from time to time, you might not want to have a framework which “holds you back” or provides functionalities which you might not need.
Advantages and disadvantages of each approach
- Build faster: The big advantage is, that you can build faster. In a world, where you want to save money and need to get results quickly, this approach makes sense. A lot of functionalities, like forms, security features are already available and can be built-in fast.
- Easier for junior developers: A junior developer might make many mistakes when building a new web application (painting a new picture from scratch), but by using a PHP framework, he or she can rely on best practices.
- Building more securely: Enterprise- and other web applications are supposed to be secure. These security features are in-built in Laravel and other technologies.
- Less flexible: Sometimes you cannot just do things from scratch, but have to built on functionalities which might not be needed in that particular project.
- Overhead: This also connects back to the first point of flexibility. You might not need all the things which come with the framework.
2) Pure PHP
- Flexibility: Build whatever you want. Build a new PHP framework which you can reuse for other projects if needed.
- You are in control: You have the steering wheel. Make the application as fast as you want, build some great scalability into it.
- More time needed for development: For smaller applications, the time for development might be the same as with frameworks. But when it comes to medium to large applications, much more time is needed for development.
- Structure needs to be followed: In Laravel and similar technologies, there is already a best-practice path you can follow in web development. This is not the case for pure PHP. Here you need to follow web development practices which are not in-built. You need to have the discipline to follow them. Otherwise, you will end up with the so-called spaghetti code for which PHP does not have a good reputation.
Other things to consider
For a long time, PHP was considered as an outdated technology. Especially Ruby on Rails was looked upon as a great alternative.
Especially the spaghetti code argument from before, was one reason why a lot of companies have shied away from using this technology.
With Laravel this notion changed. The adoption rate has increased manifold. Especially Zend developers changed to Laravel.
Most projects are started with one of the frameworks. It is seldom the case, that only PHP is used.
BUT: When it comes to web solutions which are licensed to other companies (or shrink-wrap software, as you would call it), those solutions often times are made in PHP.
PHP has become widespread in the last few years
Here some technologies which are built on PHP or PHP frameworks:
- Shopware: An online shop system which is widely used in medium-sized companies in Central Europe.
- Magento: This shopsystem is based on Zend and is used by medium sized companies world wide.
- WordPress: Who does not know WordPress? It is the most widely used Content Management System in the world. Other examples are TYPO3, Drupal and Contao.
- A large number of custom web solutions: In this post, it has been mentioned several times. There are many ERP, CRM, Accounting, Marketing, Sales-software solutions built with PHP.
If you are building some custom solutions for your clients, like an enterprise client, who needs a web application to improve their processes or having a software solution for their marketing department (enter any other department), then use a PHP framework. Because development will be faster (which is usually a requirement by these types of clients) and also it will be cheaper to develop (which will help in the sales process).
If you are building a solution for yourself, which you want to license to other companies or web users. Then ask yourself this: Is it a more standard web solution, like an online platform for comparing prices, or some other standard solution. Or do you need to have a very specific set of functionalities, like your own type of CRM system? Then core PHP might be the better solution.
What is your experience?
The author: Sascha Thattil works at Software-Developer-India.com which is a part of the YUHIRO Group. YUHIRO is a German-Indian enterprise which provides programmers to IT companies, agencies and IT departments.