Recently I tried out the Silex micro framework, creating bGrounder in the process. Getting Silex up and running on my Mac was easy-peasy. Create a new directory in my ~/Sites folder. Download the Silex PHAR (PHP archive) file. Create an application bootstrap file. Go.
I ran into trouble when I pushed my work up to my Dreamhost account. The application was failing silently. Running silex.phar on the command line resulted in meaningless errors.
After a fair bit of Duck-Duck-Go-ing (Duck-Duck-Goosing? Quacking?) I found squat. After dumping out a PHP info page I realized that Dreamhost is using Suhosin (which is a good thing). This was the culprit.
The Silex documentation provides configuration examples showing how to configure PHP and Suhosin to work with the Silex framework. Fortunately, Dreamhost lets you override the system default PHP.ini with your own.
In order to this work you should have PHP 5.3.x FastCGI enabled for your domain. Leave “Extra web security” on so you feel snuggly and safe in your bed at night.
Make sure your login account (your FTP user) has shell access enabled – this configuration cannot be done without shell access.
Follow the instructions on the Dreamhost support wiki for replacing the system php.ini. If you don’t know what any of those instructions mean, this is not for you. Contact support and ask nicely for them to do it for you.
Once you have a shiny new ini file (the file will be named “phpini”) look for the following line:
;;; VALUES BELOW WILL OVERRIDE ANY SET ABOVE!
Above this line are system defaults. Leave them be. Below this line you will add your customizations.
Add the following recommended configurations from the Silex documentation:
detect_unicode = Off phar.readonly = Off phar.require_hash = Off suhosin.executor.include.whitelist = phar
And then add the following to ensure that the PHAR extension is loaded:
Then follow the Dreamhost instructions for forcing PHP to reload the configuration – or go make some coffee and come back in 15 minutes or so. Dreamhost will eventually reload the configs automatically.
Silex should now run fine, both in the browser and on the command line. Of course your mileage may vary.