The definitive guide of Symfony 1.1

3.2. 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:

  • 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.

Lime is 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.

Tip The symfony framework is licensed under a MIT license. All the copyrights for the bundled third party libraries can be found in the COPYRIGHT file and the associated licenses are stored in the licenses/ directory.

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 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.1.0.tgz ...
Starting to download symfony-1.1.0.tgz (1,283,270 bytes)
.................................................................
.................................................................
.............done: 1,283,270 bytes
install ok: channel://pear.symfony-project.com/symfony-1.1.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.1.0 (/path/to/the/pear/symfony/lib/dir)

The symfony libraries are now installed in directories as follows:

  • $php_dir/symfony/ contains the main libraries.
  • $data_dir/symfony/ contains the web assets used by symfony default modules.
  • $doc_dir/symfony/ contains the documentation.
  • $test_dir/symfony/ contains symfony core unit and functional 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_1_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.1.0 (/path/to/the/svn/symfony/lib/dir)

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 path defined in the project's config/ProjectConfiguration.class.php file, as follows:

<?php

require_once '/path/to/symfony/lib/autoload/sfCoreAutoload.class.php';
sfCoreAutoload::register();

class ProjectConfiguration extends sfProjectConfiguration
{
  // ...
}

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 (http://pear.symfony-project.com/get/symfony-1.1.0.tgz) and unpack it somewhere. You will have the same result as with a checkout.