Welcome to AboutHalf

menu - http://abouthalf.com

Configuring your Dreamhost account for Silex

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.

Settings for PHP

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:

extension=phar.so 

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.

Related posts

  • Related posts in your WordPress template

    Since most visitors to Abouthalf.com are coming from Google or Twitter, I thought I would make it easier for folks (and Google) to find related content. Previously, a “link” formatted post would have precious little there beyond my commentary and the link itself. Likewise a picture post would have a picture and nothing else. To […]

  • Creating a zip file with PHP’s ZipArchive

    Rob Allen demonstrates how to create a ZIP archive with PHP 5.2. Handy.

  • Create APIs with Apigility

    Apigility is a new tool from the makers of Zend Framework for quickly creating REST APIs for web or mobile applications. Apigility is basically a PHP code generator with a web interface. You run Apigility locally using Apache or PHP’s built in development server. The tool provides a simple interface for creating database connections and […]

  • PHP & MySQL on OS X Mavericks

    Rob Allen on getting PHP and MySQL set up on Apple’s latest operating system.

  • MySQL authentication in Silex, the PHP micro-framework « BubbleCode by Johann Reinke

    A nice walk-through for setting up user authentication in Silex, by Johann Reinke.

  • Short-stack Framework

    Fabien Potencier is cramming an entire Symfony2 PHP application into a single file.

  • Adding PHP include paths to a project managed by Composer

    I was doing a little work on Archie’s Recipes; I found that I couldn’t use Composer to update my dependencies because I had manually hacked up the autoload.php file with a manual PHP include path configuration. After a little digging I discovered that Composer supports an include path property for legacy projects (like Zend Framework […]

  • Adding Zend Search Lucene to a Silex project

    Recently I added a search feature to Archie’s Recipes using Zend Search Lucene. The site is semi-static, relying upon the PHP micro-framework Silex to format static HTML files with layout templates (using Twig), provide a simple email contact form, and add a few simple navigational features (discussed here previously). Zend Search Lucene natively supports indexing […]

  • Archie’s Recipes

    Over the Christmas holiday I found a little bit of quiet time to get a project off the ground. Years ago, when my grandparents passed away, my family uncovered (rediscovered?) a recipe book, handwritten by my great grandfather on my mother’s side. The book itself was an old ledger, lined paper with vertical columns for […]

  • PHP on Mountain Lion

    Setting up PHP & MySQL on OS X 10.8 Mountain Lion. via Rob Allen’s DevNotes.