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:

you@yourdomain.com [/tmp]# cd
you@yourdomain.com [~]# mkdir php
you@yourdomain.com [~]# mkdir php/lib
you@yourdomain.com [~]# mkdir php/lib/vendor
you@yourdomain.com [~]# cd php/lib/vendor
you@yourdomain.com [~/vendor]# wget http://www.symfony-project.org/get/symfony-1.4.1.tgz
--06:15:44-- http://www.symfony-project.org/get/symfony-1.4.1.tgz
=> `symfony-1.4.1.tgz.2'
Resolving www.symfony-project.org... 217.174.222.79
Connecting to www.symfony-project.org|217.174.222.79|: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]
you@yourdomain.com [~/vendor]# tar zxpf symfony-1.4.1.tgz
you@yourdomain.com [~/vendor]# mv symfony-1.4.1 symfony
you@yourdomain.com [~/vendor]# rm -fr symfony-*

2 – Test your Symfony installation

You can test your installation and display the symfony version:

you@yourdomain.com [~]# 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:

you@yourdomain.com [~]# cd ~/php
you@yourdomain.com [~]# pwd
/home3/you/php

-or-

you@yourdomain.com [~]# find ~/php -name php
/home3/you/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

you@yourdomain.com [~]# 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"

Conclusion

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:

PATH=$PATH:$HOME/php/lib/vendor/symfony/data/bin/
export PATH

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top