Install Symfony Without PEAR

A lot of web hosts have limited or nonexistent support for PEAR, the pear command will throw errors on most commands or not work at all, in order to install Symfony on such hosts you will need to download the Symfony package, copy Symfony files to your home directory and make them easily accessible from PHP scripts by modifying the include_path directive setting.

In order to complete these steps faster, we will prefer using SSH to download or edit files and to create folder instead of using FTP, FTP will take a lot of time compared to SSH… Let’s start.

1 – Download and Install Symfony

Login to your account using SSH, if you are already logged in make sure your current working directory is your home directory (~), then create a “php” folder where you will download the symfony package, we will use the same directory structure used on the Symfony documentation, this will allow you to follow the documentation examples without changing directory names etc.

Before issuing the following commands, grab the link of the latest symfony version from Symfony website, for the purposes of this tutorial you will have to download the  source .tgz file, the text  written in red font will be different depending on the Symfony version: [/tmp]# cd [~]# mkdir php [~]# mkdir php/lib [~]# mkdir php/lib/vendor [~]# cd php/lib/vendor [~/vendor]# wget
=> `symfony-1.4.1.tgz.2'
Connecting to||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3,210,838 (3.1M) [application/x-gzip]100%[===================================================================>] 3,210,838 1.34M/s
06:15:48 (1.34 MB/s) - `symfony-1.4.1.tgz.2' saved [3210838/3210838] [~/vendor]# tar zxpf symfony-1.4.1.tgz [~/vendor]# mv symfony-1.4.1 symfony [~/vendor]# rm -fr symfony-*

2 – Test your Symfony installation

You can test your installation and display the symfony version: [~]# php -q  php/lib/vendor/symfony/data/bin/symfony -V
symfony version 1.4.1 (/home/you/php/lib/vendor/symfony/lib)

3 – Tell PHP where to find Symfony files

Symfony files are now available in your server, but you still need to tell php where to find them easily. For that you need to modify your PHP include_path and add the “php” folder.

We need to know the php folder absolute path, for this we will “cd” to the “php” directory and issue the “pwd” command: [~]# cd ~/php [~]# pwd

-or- [~]# find ~/php -name php

There are different solutions for altering your PHP include_path, you will choose the one that meets your needs.
[See: How to modify PHP include_path]

In this tutorial, I will assume that you are relying on a global php.ini file .

Open you php.ini file for edit [~]# nano /x/y/z/php.ini

Look for the include_path directive setting, something like this:

include_path = ".:/usr/lib/php:/usr/local/lib/php"

you can find it easily by using nano’s search featrure:

  • Press CTRL+W
  • Type the search string and press RETURN, we are interested in the string include_path
  • Press CTRL+W then RETURN until you find something that resembles the code above.

Add the php absolute path to your php include_path like this

include_path = ".:/usr/lib/php:/usr/local/lib/php:/home3/you/php"


At this point you can use symphony almost as if you installed it using the PEAR pear command. You can use the same method to install other PEAR packages. One more thing you can do is to alter your shell PATH to add the symfony command:

Open .bash_profile add the following line AT THE END OF THE FILE:

export PATH

Leave a comment

Your email address will not be published.