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 build system used by Propel to generate the model classes.
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.
3.2.1. 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
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
Tip 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
3.2.2. 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/ .
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:
'/path/to/symfony/lib'; $sf_symfony_data_dir = '/path/to/symfony/data';$sf_symfony_lib_dir =
Chapter 19 proposes other ways to link a project with a symfony installation (including symbolic links and relative paths).
Tip Alternatively, you can also download the PEAR package (pear.symfony-project.com/get/symfony-1.0.0.tgz) and unpack it somewhere. You will have the same result as with a checkout.