Minimalist Twitter Bootstrap Symfony 2 Bundle

I was looking for a minimalist way to use Twitter Bootstrap and Symfony 2 in a clean way. The solution I came up with is as follows:

  1. Create a new bundle.
  2. Register the bundle.
  3. Deploy the resources.

Create a new bundle

I created my bundle by hand, omitting some of the stuff you get when you generate the bundle via php app/console generate:bundle. The folder structure underneath the src directory looks as follows:

-- Acme
   |-- TwitterBundle
       |-- Resources
       |   |--public
       |      |--[TwitterBootstrapFiles]
       |-- AcmeTwitterBundle.php

The content of AcmeTwitterBundle.php is:


namespace Acme\TwitterBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class AcmeTwitterBundle extends Bundle

Register the bundle

To register the bundle add new Acme\TwitterBundle\OnTimeTwitterBundle() to the $bundles array in app/AppKernel::registerBundles().

Deploy the resources

To deploy the files just execute php app/console assets:install --symlink web/.

Tags: ,

Comments off

Getting Symfony2 to run under PLESK

I had a bit of trouble getting Symfony 2 setup properly under PLESK (10.2.0).

I first created a subdomain using the “web” directory of Symfony 2 as document root for the vhost.

However, I seemed to could not get rid of the errors calling config.php telling me, that app/cache and app/logs were not writeable by the server. After searching the web top to bottom and having a look at the output of php_info() I identified the culprit. PLESK sets open_basedir (the topmost directory that is accessible by your web server) to the document root:

open_basedir var/www/vhosts/<YOURDOMAIN>/ <SUBDOMAINHTTPDOCS>/Symfony/web/:/tmp/

To remedy this place a file called “vhost.conf” under /var/www/vhost/<YOURDOMAIN>/subdomains/ <SUBDOMAIN>/conf containing directives overriding PLESK’s settings, e.g.:

<Directory /var/www/vhosts/YOURDOMAIN/DOCUMENTROOT/Symfony/web>

<IfModule mod_php4.c>
php_admin_flag engine on
php_admin_flag safe_mode off
php_admin_value open_basedir /var/www/vhosts/YOURDOMAIN/SUBDOMAINHTTPDOCS/:/tmp/:

<IfModule mod_php5.c>
php_admin_flag engine on
php_admin_flag safe_mode off
php_admin_value open_basedir /var/www/vhosts/YOURDOMAIN/SUBDOMAINHTTPDOCS/:/tmp/:


Now to get the settings into the system run as root:

/usr/local/psa/admin/bin/httpdmng --reconfigure-all

Then restart Apache:

apache2ctl restart

Tags: , , , , ,

Comments off