Hacking Symfony Application in A Shared Hosting

In a shared hosting environment, you may not have a full access to the server. Everything has already been installed. But a least they provide a secure shell (SSH).

I have successfully deploy a syfmony 1.2 application in a shared hosting, surely with a hacking.

PDO Hack

Symfony 1.2 at least need PHP 5.2.4 and above. So if your PHP version is 5.2.0 and you're using MySQL database, make sure to activate PDO::MYSQL_ATTR_USE_BUFFERED_QUERY for buffered MYSQL Api.

Edit your databases.yml:

      classname:  DebugPDO

    class:        sfPropelDatabase
      dsn:        mysql:dbname=your_db;host=localhost
      username:   root
      password:   your_password
      encoding:   utf8
      persistent: true
      pooling:    true
      classname:  PropelPDO
        MYSQL_ATTR_USE_BUFFERED_QUERY:  {value: on}

Symfony CLI Hack

Usually, we can customize the php.ini file for web server, but not for the PHP CLI. Unfortunately, the PDO extension for PHP CLI is not enabled by default. As in shared hosting environment, there are no write access to system configuration.

Try this:

$ php -i | grep PDO

If you got an output telling about PDO extensions has been enabled then, you don't need this hack.

First, we can create our own php.ini file to be passed to the PHP CLI, and put in a writable directory, for example in the home directory:

# ~/php.ini

Wrap the symfony command to make sure PHP CLI is using our custom php.ini, create the script and name it symfony.sh. Put in home directory for ease the access:

# ~/symfony.sh
cd /path/to/myproject
php -c ~/php.ini -f symfony -- $*

Make sure the script is executable:

$ chmod u+x ~/symfony.sh

Now you can launch the symfony CLI from within your home directory by issuing:

$ ./symfony.sh [command]


  1. customhosting

    Really informative!!

  2. You are awesome.. I had the same problem, and spent considerable time explaining the requirement to the web-hosting people…who still dont get it 🙁 … your hack works perfectly .. probably might want to increase the memory limit from 64M to something higher though. phing quickly uses up all the memory and ends with a memory exhausted option .. Thanks a ton. …

  3. Hackers are more intelligent than developers, it would be more secure to use Dedicated application hosting service like one provided by Onthenetoffice.

  4. apakah itu bisa digunakan di semua share hosting??apakah yang penting ada akses ssh ke server??

  5. using:


    instead of above mentioned {value: on} worked much better for me.

Leave a Reply