There are many PHP frameworks available for a developer to choose from – Zend, Symfony, CakePHP, CodeIgniter to name a few. All these frameworks provide a solid structure for the code along with in-built library to address commonly needed programming tasks which makes life easier for the developer. Framework allows a developer to creatively focus on the project by minimizing the amount of code that needs to be written for a given task.
We shall be discussing two frameworks here today – Symfony and CodeIgniter.
To first note down a few similarities between the two:
- Both the frameworks follow MVC architecture, which gives us distinct separation of code in terms of logic, view and database interaction.
- Use configuration files to help you maintain vital metadata, such as the location of the database, base URLs, and the like.
- Provides helpers classes for various features.
- Allow the developer to extend the core code and build their own libraries and helper functions.
- Both support caching, multiple databases, form support, form validations and other common features.
Both the frameworks are very similar in the sense that they allow a platform to web developers to easily create their application in minimum amount of time and effort. But they differ in terms of implementation and the features they provide.
- One of the biggest difference between the two frameworks is the ease of use. CodeIgniter is pretty easy to start with where as Symfony has a distinct learning curve and can be little difficult to start with.
- CodeIgniter has a very small footprint, which is only about 1MB where as Symfony comes to around 5MB. This is due to the fact that Symfony comes bundled with many 3rd party libraries (which one might not be using at all). This also makes Symfony slightly slower in the run-time compared to CodeIgniter.
- Installing Symfony can be tricky on shared hosting as it has PEAR dependency and requires shell/command line access for setting up projects, creating modules and other tasks, where as setting up CodeIgniter is as easy as copying the source folder on the server and changing a single line in the config file.
- Another area of difference between the two frameworks in the PHP version support. Symfony only supports PHP 5 where as CodeIgniter supports both PHP 4 and 5. This is due to the fact that Symfony is developed fully with Object Oriented approach.
- Symfony facilitates user with auto code generation for modules, models, database etc which is missing from CodeIgniter. Symfony comes bundled up with propel/doctrine ORM tool which provides wrappers for database functions. This feature is not available by default in CodeIgniter but can be integrated separately.
- Symfony provides in-built Ajax support, which is lacking from CodeIgniter.
- Debugging capabilities of these frameworks differ a lot. Symfony provides a debug toolbar in development mode which provides information about database connections, load time, parameters passed, session details among other things. This helps is analyzing and optimizing an application to a great extent. A similar feature is not available in CodeIgniter.
- Symfony CLI provides commands to quickly (and effortlessly) create an admin backend for the generated model classes. Again, no such feature is available in CodeIgniter.
- CodeIgniter is a simple and easy framework to use. It give the developer options to implement the application as desired and is flexible in implementation. Symfony on the other hand is a very powerful but somewhat rigid framework which follows convention where ever possible. Symfony is all about best practices whereas CI seems to take a more pragmatic route.
Whenever we compare things, we’ll always have pros and cons but that doesn’t necessarily make one thing better that the other. The same applies here as well. Both the frameworks have their own advantages/disadvantages and should be used according to the requirements.
In my opinion CodeIgniter works well for something quick and small, Symfony work wonders when it comes for complicated projects.