Wednesday, December 14, 2011

A (Big) Dot Release

Although dot releases don't get as much attention as major releases , this one should definitely get highlighted:

      "Zend is pleased to announce the release of Zend Studio 9.0.1!"

This new release focuses on improving source code editing experience, improving editor performance, smart indentation when pasting code. It also extends the code formatter so PHP comments are well structured. Working with PHPUnit made easier with the addition of smart configuration (and bootstrap)  detection. Community plugins updates provide advanced features with Git, ZenCoding and Symfony2.

The changes include:
  • Improved editor performance for multi-line statements and auto indentation scenarios
  • Adjust indentation when pasting code
  • New code formatter rules for PHP Comments
  • Disable/Enable Code formatter with special @formatter:off/on tags
  • Git history graph
  • PHPUnit auto-detection of configuration (and bootstrap) file
  • Improved PHP Class creation for namespace code generation
  • Easy installation of community plugins ZenCoding and Symfony2 and Twig 
  • Various bug fixes

Monday, December 05, 2011

Rewrite Rulez!!!

While common Web frameworks provide a set of mod_rewrite rules in their default application, it is left to the developer to align these rules according to the Apache host configuration. For example if you use an alias when setting up a Symfony application then a RewriteBase directive must be added to the application rules. This is a common change that is required to keep the original list (provided by the framework) as is.

To this end a post-deployment action can be added to fix the RewriteBase directive in the '.htaccess' file. In a previous post, application deployment scripts were used to help chmod application's resources. This time I am going to use deployment hooks to modify the RewriteBase directive automatically after deploying the Symfony2Cloud application.

In the deployment script you can find this code:

// get application location
$appLocation = getenv('ZS_APPLICATION_BASE_DIR');
// modify htaccess
$htaccess_file = $appLocation . '/web/.htaccess';
$explode = explode ( '/', $appLocation );
$appname = $explode [sizeof ( $explode ) - 2];
$content = file_get_contents ( $htaccess_file );
$content = str_replace ( '<application-name>', $appname, $content );
file_put_contents ( $htaccess_file, $content );

In details: The application location is used to resolve its alias. Then the alias name is used to replace the .htaccess file content so instead of "RewriteBase /<application-name>" it will show up as "RewriteBase /Symfony2Cloud".

Assuming that you use Zend SDK and the following deploy command:

zend deploy application -r git://

Symfony2Cloud is now deployed and ready to use with this .htaccess:

<IfModule mod_rewrite.c>
 RewriteBase /Symfony2Cloud

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ app_dev.php [QSA,L]