PHP Framework Comparison
Yes this is yet another PHP Framework comparison. A few months back I was trying to decide which PHP framework to use on a project. I wanted to use a currently popular framework because that way I would get the best support from the devoted contributors and users. Choosing a popular or active project is important when dealing with open source tools.
From my research I found that cakePHP, Zend Framework, and codeIgniter are currently the most popular PHP frameworks. Below are my notes and thoughts about of each framework.
Some of this will only make since if you are familiar with MVC frameworks, if you are not read this first http://en.wikipedia.org/wiki/Model-view-controller
cakePHP
Google results
- 4.75 million (term: cakephp)
Books
- Beginning CakePHP Novice Professional
- Practical CakePHP Projects
- CakePHP Application Development Step by step
Mailing List/Forum Activity
- Mailing list is a google group: http://groups.google.com/group/cake-php?pli=1
- seems to very active with around 2k posts a month. More details here http://groups.google.com/group/cake-php/about
Pros
- CoC type development
- Has a scaffolding option that allows you to test your basic database and model design without having to create a single view.
- Model relationship management. CakePHP has built in functionality to automatically load arrays of related model entities based on your model and database design. These are stored in model propeties named $belongsTo, $hasMany, and $belongsToAndHasMany. You can even control if cakePHP should load the related models, in case there is instance you don’t them.
- Automated code creation with bake script. The bake script generates controller methods, models, and even views. You can then edit them to learn more about how to use cake correctly.
- Focus is to keep the controllers light by having most of the functionality in the model or in something called a behavior which could be seen as a simple service layer
Cons
- I find the layout of the actual cakephp.org site confusing. For example the main menu has two items that at first glance I have no idea what they mean Bakery and Forge.
- Very array based. Which not really a bad thing most PHP frameworks and applications are array based. When possible I would rather use objects instead of arrays. Defined methods and properties can make coding a lot easier.
Notes
- Can be used by a novice or veteran PHP developer. Very similar to CodeIgniter. Very different from ZendFramework.
Zend Framework
Google results
- 4.63 million google results – (term: “zend framework”)
Books
- Zend Framework In Action
- Architects Guide to Programming Zend Framework
- Zend Framework Official Programmer Reference
- Beginning Zend Framework
- Pro Zend Framework CMS Building
Mailing List/Forum Activity
- Moderately active. Couldn’t tell exactly how active because the archive does not show dates
- http://framework.zend.com/wiki/display/ZFDEV/Mailing+Lists
Pros
- requires PHP 5.1.4 or newer. To me this is a pro because it forces you to use PHP5 which is more object oriented. Some may see this as a con.
- can pick and choose which features you want to use. A more open development path. Which is good for experienced developers.
Cons
- Doesn’t seem to follow CoC as much as cakePHP or CI
too much “just because” configuration.
Notes
- More for a veteran PHP developer. Very different from CakePHP and
CodeIgniter
I would definitely buy a book to help evaluate this framework fully.
CodeIgniter
Google results
- 714k google results – (term: codeigniter)
Books
- Professional CodeIgniter
- Practical CodeIgniter Projects Building
- Creating Microsite Manager with CodeIgniter
Mailing List/Forum Activity
- Very active.
http://codeigniter.com/forums/
Pros
- the manual/tutorial is excellent
- concise framework that allows u to get started very quickly
Cons
- Did not come with .htaccess file (problem for people new to apache)
- A lot of duplication in the controllers. A controller heavy framework
Notes
- Can be used be a novice or veteran PHP developer. Very similar to CakePHP. Very different than Zend Framework.
PropertyPlaceholderConfigurer with Default Values
My current project relies heavily on Spring. We use the PropertyPlaceholderConfigurer so that our application contexts can pull values from the properties files and inject them into our beans. This is all very common. This means when the beans are being created and a value like ${someproperty} shows up, the BeanFactory visits the configured properties files to find the value for someproperty and injects that value into the bean.
The problem arises when a bean is configured using such a placeholder but the requested property is not found. This causes our application to fail to start.
Our solution was to extend PropertyPlaceholderConfigurer to provide default values. These default values are loaded before loading any properties files. Firs well glance over the java class.
import java.io.IOException;
import java.util.Properties;
import java.util.Map;
import java.util.HashMap;
public class DefaultPropertyPlaceholderConfigurer
extends org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
{
private Map<String, String> startingProperties = new HashMap<String, String>();
public void setStartingProperties(Map<String, String> startingProperties)
{
this.startingProperties = startingProperties;
}
public DefaultPropertyPlaceholderConfigurer()
{
try
{
loadDefaultProperties();
}
catch (IOException e)
{
logger.warn("failed to load default properties", e);
}
}
private void loadDefaultProperties()
throws IOException
{
final Properties defaultProperties = new Properties();
for(Map.Entry<String,String> entry : startingProperties.entrySet())
{
defaultProperties.put(entry.getKey(), entry.getValue());
}
this.setPropertiesArray(new Properties[]{defaultProperties});
}
}
And the XML bean definition for our new PropertyPlaceholderConfigurer.
<bean id="propertyConfigurer"
class="app.factory.config.DefaultPropertyPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="startingProperties">
<map>
<entry key="one.two.three" value="123" />
</map>
</property>
<property name="locations">
<list>
<value>/WEB-INF/classes/preferences.properties</value>
</list>
</property>
</bean>
So now, when one.two.three is not included in the properties file preferences.properties the value will be initialized to 123. The value is defined in the properties file, the default value of 123 is overridden with the custom value.
Use Case
Here are the details on our specific use case. We release updates that add new properties, however, in order for the user to run the updates, the application has to start first (it is a web application). If the property is not set then the BeanFactory fails to start the application because it can not resolve the placeholder. So the software can’t start without running the updates first, but the updates can not be run until the application is started.
Now the web application starts and uses the default value, the administrator can run the updates which add the custom values to the preferences.properties file, and the user is prompted to restart the software after the updates are complete. The restart is required to read the new values into the bean.
Oops
While I was writing this post I realized that there was a much simpler way to provide default properties without extending the base class.
Any ideas as to how I could have done it?
Greatest Barriers to Open-Source Adoption
In May of 2008 CIO.com asked 328 information technology business executives and managers if they use open source applications in their organizations. The good news is that 53% answered that they are already using open source tools. The survey also uncovered why the other 47% are not using open source tools.
| Concern | Percent |
|---|---|
| Product support concerns | 45% |
| Awareness/knowledge of available solutions | 29% |
| Security concerns | 26% |
| Lack of support by management | 22% |
| Licensing or legal concerns | 21% |
| Investment in architecture from other vendor(s) | 20% |
| Software quality issues | 20% |
| Customization concerns | 15% |
| Not relevant to our product or service | 7% |
| Pressure on open-source providers by commercial vendors | 5% |
| Software cost allocation policies | 2% |
| Other | 9% |
What can we learn from the results of this survey?
Corporate Software Developers
Support
For corporate software developers, the number one reason that your organizations do not allow open source products is because your bosses are afraid that there is no support for the tool. They are unaware of the support options that are available to your organization. You need to show management that a particular tool is backed by a company who offers support. Show him or her the web page that explains the various support options that they provide.
If there is indeed no support for a given tool, then you are the support. Explain how you have the source code, and how well it is documented. Discuss the benefits of an open product and how you can get help from user groups via forums, IRC, and mailing lists. Put management at ease by showing them these mailing lists, and how active they are, or point out how many questions in the forum get answered on a daily basis.
Awareness
The number two reason was awareness. This is easy to fix. Just show them the projects. Show the alternatives. Some projects even do the work of listing the alternatives for you. In some cases, you can show how the alternatives are interchangeable. Take for example Hibernate and an open source database. You could describe how a project using Hibernate backed by MySQL, two popular open source projects, can be migrated to Hibernate and Postgres in seconds, with no SQL changes, no new stored procedures and almost no risk.
The point is, your managers are not surfing the internet researching open source projects and their alternatives. You probably are and you probably have more to gain in switching to these open source solutions, so the weight is on your shoulders to make your managers aware. You have to bring the projects to your managers and present them in a way to showcase the size of their communities, the available support, and the commitment of the project’s developers.
Open Source Project Leaders
For project leaders of open source projects, this survey should scream out to you. If we review what these managers are telling us, and we can alleviate their concerns, then we can get our tools into the corporate domain. Again, if we look at the top two reasons we see that corporate managers are telling us what they want and what they need.
Support
First is support. If you can provide support, then you can mitigate their number one concern. Support can come in many forms. The support that they were referring to in the survey was probably paid support. This is harder for smaller open source projects to setup but that doesn’t mean you can’t offer many lower tiers of support. Mailing lists, IRC channels, forums, and issue lists are certainly valid types of support. If you don’t offer paid support but do offer the other types of support you are really leaving it on the corporate developer to sell those forms of support to their managers. If you can’t offer paid support maybe you know someone who can. Identify these people on your project’s site.
Try to stay active in your forums and mailing lists, don’t leave any questions unanswered, acknowledge every issue that is submitted, and hopefully this will show managers that while they can not pay for premium support, the project is indeed supported by and active and responsive development team.
Awareness
And again, the number two reason that some organizations have not adopted your product is because the big wigs don’t even know that you exist. You have to promote your project and you have to stay committed to promoting your project. Most of us get into open source projects to write code, but project promotion is as important as the code and is often an overlooked or under appreciated aspect of open source projects.
There are many ways to promote your project. Pushing Pixel’s Kirill Grouchnikov point out a few ways in Party of One: Promote. You can promote your project by simply spending some time writing documentation, or write up some tutorials or design decision explanations in a simple blog post. For my project, Architecture Rules, we recently posted Architecture Rules 101 and Architecture Rules 102 which provided simple tutorials for creating easy configurations. These two tutorials have landed us dozens of new users. We also use a wiki platform to document our project and provide code examples. These are simple things that we have done to promote our project and to increase awareness.
Conclusion
So weather you’re a software developer looking to introduce open source tools to your environment, or a project leader wanting to find more users, look to product support and project promotion. These two project areas will alleviate up to 80% of a manager’s concerns and increase both the end user developer and the project leader’s chances of the open source project finding its way into the corporate and mainstream domains.







