SymfonySymfony

Home | News | Download | Top 10 Frameworks | Add New PHP Framework | Reviews | PHP Frameworks Forum | PHP Frameworks Books|PHP IDE Compare

Introduction

Symfony is a web application framework for PHP5 projects.

It aims to speed up the creation and maintenance of web applications, and to replace the repetitive coding tasks by power, control and pleasure.

The very small number of prerequisites make symfony easy to install on any configuration; you just need Unix or Windows with a web server and PHP 5 installed. It is compatible with almost every database system. In addition, it has a very small overhead, so the benefits of the framework don't come at the cost of an increase of hosting costs.

Using symfony is so natural and easy for people used to PHP and the design patterns of Internet applications that the learning curve is reduced to less than a day. The clean design and code readability will keep your delays short. Developers can apply agile development principles (such as DRY, KISS or the XP philosophy) and focus on applicative logic without losing time to write endless XML configuration files.

Symfony is aimed at building robust applications in an enterprise context. This means that you have full control over the configuration: from the directory structure to the foreign libraries, almost everything can be customized. To match your enterprise's development guidelines, symfony is bundled with additional tools helping you to test, debug and document your project.

Last but not least, by choosing symfony you get the benefits of an active open-source community. It is entirely free and published under the MIT license.

Symfony is sponsored by Sensio, a French Web Agency well known for its innovative views on web development.



Latest version1.0.9
PHP4-
PHP5Symfony Support PHP5
MVCSymfony Support MVC
Multiple DBSymfony Support Multiple DB
ORMSymfony Support ORM
DB ObjectsSymfony Support DB Objects
Templates-
CachingSymfony Support Caching
ValidationSymfony Support Validation
AjaxSymfony Support Ajax
Auth ModuleSymfony Support Auth Module
ModulesSymfony Support Modules
CostFree
Official websitehttp://www.symfony-project.com/
Download URLhttp://www.symfony-project.org/content/download
Manual URLhttp://www.symfony-project.org/doc/1_0/
Installation installation chapter of the symfony book.

The sandbox

The sandbox is an empty symfony project where all the required libraries are already included, and where the basic configuration is already done. It is made for symfony beginners, who want to play with the framework or try the tutorials without installing anything.

You can download a sandbox for the latest symfony stable release sf_sandbox.tgz. Unpack it in your root web directory. Refer to the included readme file for more information.

After downloading the sandbox, you might want to follow the My first project tutorial to discover the basics of symfony development.

Source Download

If you want to customize your own installation, or if you want to browse the symfony source without installing it, you might prefer a simple download. Beware that you will have to create shortcuts to the symfony libraries and binaries if you want to use it for a project. Refer to the installation manual for more details.

Download a .tgz archive
Download the stable release from this link: http://www.symfony-project.org/get/symfony-stable.tgz
Checkout from the Subversion repository
To check out the stable release, type in a command line:
$ svn co http://svn.symfony-project.com/branches/1.0 .
To check out the trunk release, containing the latest bug fixes and enhancements, type:
$ svn co http://svn.symfony-project.com/trunk/ .
Use svn:externals
If your project is already under version control with SVN, you might want to use symfony as a svn:externals dependency. To do so, browse to the root of the project where you want to put symfony in, and type:
$ svn propedit svn:externals lib/vendor

// your favorite text editor then opens, and you must then type
symfony http://svn.symfony-project.com/branches/1.0
Browse the source online
Head to the source browser of the symfony trac.

PEAR installation

The PEAR installation is for those who want to run several symfony-based projects, with an easy way to upgrade. It requires PEAR version 1.4.0 or higher, which is bundled in most PHP distributions.

Type in the command line:

$ pear channel-discover pear.symfony-project.com

Then, to install the latest stable release:

$ pear install symfony/symfony

or to install the nightly release:

$ pear install symfony/symfony-beta

PEAR also provides an easy way to upgrade symfony, for instance to get the latest beta version:

$ pear upgrade symfony/symfony-beta

Linux installation

Some Linux distributions have symfony packages. As of now, packages have been created for Debian like distributions and SUSE.

  • Debian/Ubuntu package:
    • Add to your /etc/apt/sources.list:
        deb http://www.symfony-project.org/get debian/
    • Run as root:
        $ apt-get update
    • Install it:
        $ apt-get install php5-symfony
  • SUSE package is available in the server:php:applications repository:
    
    http://software.opensuse.org/download/server:/php:/applications/
        

User-contributed guides

The symfony wiki contains a few articles describing step-by-step installations on various platforms.

The forum has a dedicated section where many installation issues have already been solved, and where you will find a symfony user willing to help you in minutes if you have a new problem.

System Requirements

As you've learned in previous chapters, the symfony framework is a set of files written in PHP. A symfony project uses these files, so installing symfony means getting these files and making them available for the project.

Being a PHP 5 framework, symfony requires PHP 5. Make sure you have it installed by opening a command line and typing this command:

> php -v

PHP 5.2.0 (cli) (built: Nov 2 2006 11:57:36)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies

If the version number is 5.0 or higher, then you're ready for the installation, as described in this chapter.

Installing the Sandbox

If you just want to see what symfony is capable of, you'll probably go for the fast installation. In that case, you need the sandbox.

The sandbox is a simple archive of files. It contains an empty symfony project including all the required libraries (symfony, pake, lime, Creole, Propel, and Phing), a default application, and basic configuration. It will work out of the box, without specific server configuration or any additional packages.

To install it, download the sandbox archive from http://www.symfony-project.org/get/sf_sandbox.tgz. Unpack it under the root web directory configured for your server (usually web/ or www/). For the purposes of uniformity, this chapter will assume you unpacked it to the directory sf_sandbox/.

Having all the files under the root web directory is fine for your own tests in a local host, but is a bad practice in a production server. It makes all the internals of your application visible to end users.

Test your installation by executing the symfony CLI. Go to the new sf_sandbox/ directory and type the following on a *nix system:

> ./symfony -V

On Windows, issue this command:

> symfony -V

You should see the sandbox version number:

symfony version 1.0.0

Now make sure that your web server can browse the sandbox by requesting this URL:

http://localhost/sf_sandbox/web/frontend_dev.php/

You should see a congratulations page that looks like Figure 3-1, and it means that your installation is finished. If not, then an error message will guide you through the configuration changes needed. You can also refer to the "Troubleshooting" section later in this chapter.

Figure 3-1 - Sandbox congratulations page

Sandbox congratulations page

The sandbox is intended for you to practice with symfony on a local computer, not to develop complex applications that may end up on the Web. However, the version of symfony shipped with the sandbox is fully functional and equivalent to the one you can install via PEAR.

To uninstall a sandbox, just remove the sf_sandbox/ directory from your web/ folder.

Installing the Symfony Libraries

When developing an application, you will probably need to install symfony twice: once for your development environment and once for the host server (unless your host already has symfony installed). For each server, you will probably want to avoid duplication by keeping all the symfony files in a single place, whether you develop only one application or several applications.

Since the symfony framework evolves quickly, a new stable version could very well be released only a few days after your first installation. You need to think of the framework upgrade as a major concern, and that's another reason why you should share one instance of the symfony libraries across all your symfony projects.

When it comes to installing the libraries for a real application development, you have two alternatives:

  • The PEAR installation is recommended for most people. It can be easily shared and upgraded, and the installation process is straightforward.
  • The Subversion (SVN) installation is meant to be used only by advanced PHP developers, who want to take advantage of the latest patches, add features of their own, and/or contribute to the symfony project.

Symfony integrates a few other packages:

  • pake is a CLI utility.
  • lime is a unit testing utility.
  • Creole is a database abstraction engine. Just like PHP Data Objects (PDO), it provides an interface between your code and the database SQL code, and makes it possible to switch to another engine.
  • Propel is for ORM. It provides object persistence and query service.
  • Phing is a CLI for Propel.

Pake and lime are developed by the symfony team. Creole, Propel, and Phing come from another team and are released under the GNU Lesser Public General License (LGPL). All these packages are bundled with symfony.

Installing the Symfony PEAR Package

The symfony PEAR package contains the symfony libraries and all its dependencies. It also contains a script that will extend your CLI to include the symfony command.

The first step to install it is to add the symfony channel to PEAR, by issuing this command:

> pear channel-discover pear.symfony-project.com

To see the libraries available in this channel, type the following:

> pear remote-list -c symfony

Now you are ready to install the latest stable version of symfony. Issue this command:

> pear install symfony/symfony

downloading symfony-1.0.0.tgz ...
Starting to download symfony-1.0.0.tgz (1,283,270 bytes)
.................................................................
.................................................................
.............done: 1,283,270 bytes
install ok: channel://pear.symfony-project.com/symfony-1.0.0

That's it. The symfony files and CLI are installed. Check that the installation succeeded by calling the new symfony command line, asking for the version number:

> symfony -V

symfony version 1.0.0

If you prefer to install the most recent beta, which has the latest bug fixes and enhancements, type pear install symfony/symfony-beta instead. Beta releases are not completely stable and are generally not recommended for production environments.

The symfony libraries are now installed in directories as follows:

  • $php_dir/symfony/ contains the main libraries.
  • $data_dir/symfony/ contains the skeleton of symfony applications; default modules; and configuration, i18n data, and so on.
  • $doc_dir/symfony/ contains the documentation.
  • $test_dir/symfony/ contains unit tests.

The _dir variables are part of your PEAR configuration. To see their values, type the following:

> pear config-show

Checking Out Symfony from the SVN Repository

For production servers, or when PEAR is not an option, you can download the latest version of the symfony libraries directly from the symfony Subversion repository by requesting a checkout:

> mkdir /path/to/symfony

> cd /path/to/symfony
> svn checkout http://svn.symfony-project.com/tags/RELEASE_1_0_0/ .

The symfony command, available only for PEAR installations, is a call to the /path/to/symfony/data/bin/symfony script. So the following would be the equivalent to the symfony -V command for an SVN installation:

> php /path/to/symfony/data/bin/symfony -V

symfony version 1.0.0

If you chose an SVN installation, you probably already have an existing symfony project. For this project to make use of the symfony files, you need to change the two variables defined in your project's config/config.php file, as follows:

<?php
 
$sf_symfony_lib_dir  = '/path/to/symfony/lib/';

$sf_symfony_data_dir = '/path/to/symfony/data/';
 

Chapter 19 proposes other ways to link a project with a symfony installation (including symbolic links and relative paths).

Alternatively, you can also download the PEAR package (http://pear.symfony-project.com/get/symfony-1.0.0.tgz) and unpack it somewhere. You will have the same result as with a checkout.



Latest 10 Comments
 1 Rating:
 Most feature-rich php framework
 Posted by TechGuy
 2 Rating:
 I felt in love when i started working with symfony 1.0. And I'm still like to use it for PHP projects.
 Posted by Jorn
 3 Rating:
 Symfony2 was my first php framework. So i can say: understanding the mvc architecture came easly than i thought. for better and faster working you'd need a linux os.
 Posted by em
 4 Rating:
 good framwork
 Posted by vasani rajesh
 5 Rating:
 Symfony2 has a built templating engine called twig, it also incorporates the best programming practices.
 Posted by Oscar
 6 Rating:
 This framework is cool
 Posted by Adam
 7 Rating:
 powerful MVC framework
 Posted by Ferenczy
 8 Rating:
 the best
 Posted by garakkio
 9 Rating:
 If you are wanting to build a serious web application and have consistency and defined structure among multiple developers. Not to mention many plugins to help with accelerating development.
 Posted by mblackmer
 10 Rating:
 Symfony 1.4 is excellent with it's Form feature + Doctrine. Looking for Symfony 2.0
 Posted by Ankit Shah
 Read More Add comments
Recommended sites