Enter your contact information.
Enter your project information.
Step 3Choose the PHP programmers you want to hire.
Compare Free PHP Quotes
A Look at PHP 5.3 Frameworks – Symfony2
*Attention PHP Programmers* - Add A Free Listing! Get more clients.
Ever since PHP5.3 was released we have seen several new frameworks pop up in the PHP community. In this series of articles we will look at and evaluate some of the next generation PHP frameworks. Today we look at Symfony2.
Overview
Symfony2 is a full stack web enterprise framework created by well known PHP guru Fabien Potencier. The framework itself is divided up into several different packages (Bundles) which are tied together with a Kernel object. Being a full stack framework Symfony2 offers almost everything you will need out of the box:
- Model, View, Controller separation
- Database management with Doctrine2
- Templating with either straight PHP Templates or Twig
- Testing with a layer built upon PHPUnit
- Emails with SwiftMailer
- Custom form, validation, auth, event and caching systems.
One thing that distinguishes Symfony2 from other frameworks is that it relies heavily on Dependency Injection and as a result alot of configuration needs to take place. The standard of the Symfony2 is top notch, it is clearly set out, commented and tested. The full stack nature of Symfony2 is also a big strength. If you were to start a high upkeep project, you could be sure that in 5 years all components of the stack (forms, validation, templating, testing, database) would still be maintained. An overview of the architecture of a Symfony2 application can be found here.
PHP, XML or Yaml?
One of Symfony2′s unique features is that it allows you configure the majority of your application in either PHP, XML or Yaml. When Symfony2 is running in production mode, all XML or Yaml files are compiled and cached as native PHP files, so there is no performance advantage gained by using straight PHP. Frameworks such as Zend Framework only allow application settings to be defined in XML, Yaml or .ini format, Symfony2 goes a step further and allows you to specify functionality such as validations and url routes in these formats. For example, the following code snippets show how to validate the presence of the $name attribute in the Author object below.
// Sensio/HelloBundle/Author.php
class Author
{
private $name;
}
PHP
// Sensio/HelloBundle/Author.php
use SymfonyComponentValidatorMappingClassMetadata;
use SymfonyComponentsValidatorConstraintsNotBlank;
class Author
{
private $name;
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('name', new NotBlank());
}
}
Yaml
# Sensio/HelloBundle/Resources/config/validation.yml
SensioHelloBundleAuthor:
properties:
name:
- NotBlank: ~
XML
<!-- Sensio/HelloBundle/Resources/config/validation.xml -->
<class name="SensioHelloBundleAuthor">
<property name="name">
<constraint name="NotBlank" />
</property>
</class>
Bundles
Bundles are packaged classes and methods which provide functionality for your application. Symfony2 ships with bundles that are required for the framework to run. These are things like DoctrineBundle (database), TwigBundle (templating), SwiftmailerBundle (emails) and ZendBundle (Zend Framework integration). Code inside bundles must follow the defined structure and naming guidelines, specified here so that Symfony2 can automatically know where to find controllers, tests and translations. Bundles are what other frameworks would call plugins, modules or extensions. You can download Bundles developed by the community that provide features like user registration, Facebook integration and blog functionality from symfony2bundles.org.
Testing
As you could expect with any enterprise framework, Symfony2 comes with complete testing functionality. Symfony2 provides a layer on top of PHPUnit for you to define your tests. You can write standard unit tests (as you would with PHPUnit) as well as ‘functional tests’. Functional tests are essentially automated front end testing, Symfony emulates a browser request to a specific URL of your application and you define what output you are expecting to see. This could be a specific HTTP response code or some HTML on the page.
HTTP Caching
Every Symfony2 controller returns an instance of the Response object. The Response object has several methods available that allows the developer to set specific HTTP headers which are then sent to the browser. This allows the developer to have complete control over every header that is being sent back to the browser. The slides below show how powerful this feature can be.
Community
Although Symfony2 is still in pre-beta, the majority of functionality is already in the framework. All official documentation and guides can be found on the Symfony2 website Symfony-Reloaded.org. If your a Twitter user than I recommend following @fabpot (creator, developer of Symfony2), @jwage (developer Symfony2, Doctrine) and @symfony (aggregated Symfony news). An RFC was recently posted on the phpBB4 wiki suggesting that phpBB4 be built using Symfony2. If it gets accepted then we could expect the thousands of mod developers for phpBB2 & 3 would learn Symfony2 while developing mods for phpBB4.
Conclusion
I suspect developers with previous experience in Symfony1, Java and .NET would find Symfony2 perfect and won’t hesitate to use it. Those who use PHP frameworks such as Code Igniter, Kohana, CakePHP and Yii will find Symfony2 very different. The strict naming convention, long namespaces and dependency injection may put them off. If phpBB4 does decide to use Symfony2 then other open source PHP projects may follow and Symfony2 will no doubt become the most popular PHP framework. Regardless of developer preferences or immediate success, Symfony2 is an amazing piece of code and I highly suggest you try it out.
Links
Source http://query7.com/?p=867Mon, 14 Mar 2011 08:29:15 GMT
Tags: php, Web Development,
*Attention PHP Programmers* - Add A Free Listing! Get more clients.
php
Using Proxies with cURL in PHP
If you are new to using PHP and cURL please refer to the PHP cURL tutorial. It covers why you should using cURL (as opposed to file_get_contents) and goes over how to make cURL requests with a custom class.
Developing a blog with CakePHP
Web Development
Titanium Mobile Android Development: Installation
In this series of tutorials we use Appcelerator’s Titanium Mobile platform to create Android applications. This tutorial goes over the installation and configuration of the Android SDK and Titanium Mobil
This Week in Web – PHP Namespaces, NodeTuts, Kohana
Interview with Matthew Weier O’Phinney
Kevin Schroeder, tech evangelist at Zend, recently interviewed Zend Framework lead Matthew Weier O’Phinney. The two talk about Weier O’
Web Design, Implementation, and Maintenance. PHP, Javascript, JQuery, MySql
Daphne, Alabama US
Let Hamilton Arts assist you with your web design needs. We can assure you that our design will not only impress but also work within your budget.
Mesa, Arizona US
Thoreson Web Designs is a Wisconsin-based web design business located in Milwaukee. I have experience with an array of tools and programs, and understand the importance of project management.
Milwaukee, Wisconsin US
We provide affordable php website design & SEO services to our clients. Our HTML is search engine friendly and builds a solid foundation for your SEO & marketing campaign. WE provide free estimates.
New Port Richey, Florida US
Full Service Web Design/Development/Hosting Company
Davenport, Iowa US
Google Taps Danger Mouse to Show Off the Power of WebGL
Google has launched a new web-based movie experiment designed to showcase the power of WebGL-based a
Google Tweaks Search Results to Punish Ad-Heavy Websites
Google has changed its search results algorithm to punish websites that bury their content under exc
Protest SOPA: Black Out Your Website the Google-Friendly Way
Google has some advice for anyone who would like to black out their site to protest the SOPA/PIPA/OP
Chrome Covers Your Tracks with new ‘Flash Cookie’ Killer
Google has updated the dev channel of its Chrome web browser, adding a new option to delete so-calle
Getting Started With Twitter’s Embedded Tweets Feature
Somewhat lost amidst the news of Twitter’s revamped interface is a slightly more interesting t
Article Tags
PHP Programmers Articles
Live Help Chat Software
Web Design Quote
Web Design