You are browsing the archive for Symfony2.

Installing and using Coffee-Script with Assetic on Windows

15. November 2011 in Assetic, CoffeeScript, Symfony2

There are a lot of poor souls that are forced to use Windows as an OS for their daily development job. I’m one of them. I heard even of people enjoying working on Windows ;) There is one thing in common for them: Using cutting edge tools like CoffeeScript, node.js and others isn’t working easily out of the box most of the time. But in case of CoffeeScript there is good news. Since the release of Node.JS 0.6 with native windows support everything is working pretty fine. Here is what you will need to do to get it working.

Installing Node.JS

The best way using CoffeeScript is the installation via Node.js. The setup of Node.js can easily be done with the new Windows-Installer package that is available on the project site. There is nothing special here. After node.js is installed you will need to setup the node.js package manager (npm). You willneed to have a Git-Client installed on your machine. The best you can get is msysgit which brings a git bash console. Please make sure you have version 1.7.6 or newer installed on your PC. Open up a Git-Bash console and change to the folder you want to install npm (C:\Program Files for example). After that execute the following three commands:
[crayon lang=sh]> git config –system http.sslcainfo /bin/curl-ca-bundle.crt
> git clone –recursive git://
> cd npm
> node cli.js install npm -gf
You have now the node.js package manager installed.

Installing CoffeeScript

Installing CoffeeScript is now a piece of cake. Just use the following command:
[crayon lang=sh]> npm install -g coffee-script[/crayon]
The -g switch ensures that your CoffeeScript installation is available system-wide. If everything went right you can now start the CoffeeScript commandline tool from the console.

Coffee-Script commandline

If you need tutorials or reference material for CoffeeScript here is what I found useful:

Using Coffee-Script with Assetic

Working with Coffee-Script and the commandline compiler leads to uncomfortable development process. But there is light at the end of the tunnel. As with all assets Assetic will be of great help when using Coffee-Script files in your Symfony project. The AsseticBundle is part of the Symfony2 Standard Edition so there is no need to install anything. You just have to do some configuration work ahead. This is done in the app/config/config.yml file. There you have to add a filter for CoffeeScript.
By default this filter is looking at fixed folders for the bin files of CoffeeScript and node.js. These paths are unix-ones. So we need to configure the paths, so they correspond with your installation folders.
bin: c:/nodejs/bin/node.exe
node: c:/npm/bin/npm.exe
From now on there is no difference in using the CoffeeScript files with Assetic compared to unix systems. Here is how to use them in Twig-Templates.
[crayon lang=php]
{% javascripts filter=”coffee”

{% endjavascripts %}

If you need more infos on how to use CoffeeScript with Assetic take a look at the Blog of Richard Miller

How to build a great Eclipse-Environment for Symfony2-Development

7. November 2011 in IDE, Symfony2

As I wrote in my last blog post, I was surprised about how good Eclipse fits for the development of Symfony2 projects. Long years I have avoided to work with Eclipse if possible. The reason was that the plain IDE was useless for PHP development. Without a lot of plugins the feature set can’t stand the comparison with the other major IDEs (especially PHPStorm). But there are a lot of plugins, a combination of them let you build a really good Symfony2-Development environment.

So lets take a look what I did. As always I would love to hear your comments on everything that could be done better or any plugin you find it worth to install.

First of all you need a Eclipse installation. I have chosen version 3.7.1 of the “Eclipse IDE for JavaScript Web Developers” ( The first plugin to install is yedit a YAML Editor plugin for Eclipse. There are others but I found this one the best of them.  To install yedit add the Update-Site (Help->Install new Software) in Eclipse. The URL of the Update-Site is


The next plugins to install are the PDT (PHP Development Tools) and the Symfony2 plugin. Now the bumpy road lies ahead of us. The Symfony2-Plugin is in beta state at the moment and needs a development-build of the PDT to work. So installation can produce “interessting” results in form of errors. For a detailed installation instruction consult the installation page of the project. Because of the dependencies and the development speed things will change frequently.
What will you get installing the plugin? Short answer: A bunch of great little helpers for editing Symfony2 Classes. Here is my favorite list:

  • Autocomplete of route-names in Twig-Templates
  • Code-Assist of Template-paths
  • Code-Assist of Container-Services
  • Annotation-Support
  • Code-Assist for translations

For a more complete list of features please consult the Projects homepage. Here some screenshots (taken from the projects homepage)

PHP Tool integration

Next step is to get a better PHP Tool integration. As I’m addicted to Tools such PHPUnit, CodeSniffer and others I love to have them integrated directly in the IDE. And thats a thing Eclipse is lacking so far. But as always rescue comes by installing a new plugin. In this case PTI(PHP Tool Integration, The Installation can be done via the Update-Site of the Plugin ( The current version brings support for PHPUnit, PHP_CodeSniffer, PHP Depends, PHP Copy/Paste Detector. The development speed slowed down the last months, so if you like the plugin just make sure you send you congratulations to Sven Kiera (Twitter)
After installing the plugin you will have to initially configure it in the preferences (there is a new category PHP Tools there)

After installing and congiguring you get new views for your IDE. In these you can start the tools and can work through the results of them.


Chances are good that you never heard anything about WicketShell, although it is a great plugin after all. WicketShell adds a Console Shell as an Eclipse view. This is pretty useful to execute Symfony-Commandline-Operations or doing other console stuff. This is even more useful if you are using Windows because of the lack of a good console. The development activity of the plugin is low but it is usefull nonetheless. The Update-Site for installation:


The default capabilities of Eclipse/PDT are two basic settings for the idention size and the Tab policy. Compared to the possibilities of Netbeans or PHPStorm this is a shame. Luckily there is a plugin for that :) PHP Code Formatter: There is no updatesite available at the time of writing this. So you will have to download the plugin file and install it as a file (archive) in the under Help->Install New software. After installing the plugin you can creating code formatting rules that fits your Coding Style (hopefully you have one). This is totaly handy for reformating your sources with the Ctrl+Shift+F Shortcut.

Version Control

Even for the support of a version control system you will have to install a plugin. Sometimes there are more than one for the same VCS (for SVN for example). As I’m working with GIT and Mercurial most of the time, I installed these two plugins:

Git: I use EGit, update-site here:
Mercurial: I use MercurialEclipse, update-site here:

Code Coloring

Maybe you are a fan of strong colors or love dark backgrounds in your Editor windows. If this is the case the Eclipse Color Theme plugin is definitly for you. After installing the plugin from its update-site ( you can choose and install from a great set of different themes (

That’s it. That brings Eclipse on par with other IDEs. For some things (DI autocompletion, Annotation support) this installation will beat the others.

The installation still has the general problems of an Eclipse installation. The components should be touched / updated carefully. Better don’t touch then if everything is working. The Symfony2-Plugin is still beta and relies on a development build of the PDT, so any update here can break the IDE. But without this you will get a decent PHP/Symfony2 IDE and some features are really a joy to work with. Will I love it? Most probably not, but it is a good choice for all who doesn’t have the free choice or like Eclipse anyway.

The state of Symfony2 support in IDEs

4. November 2011 in IDE, Symfony, Symfony2

I have developed a lot with Symfony2 in the last months. During this time I switched my development environment a lot too find the tools that fit my workflow as good as possible. Now we have a stable release of Symfony2 available it is time to take a look at the Symfony2-Support of my favorite PHP-IDEs.


Years ago Eclipse was my main IDE for PHP development. I switched to Netbeans with the version 6.5 because it was faster, more stable and got symfony 1 support in one of the 6.x versions. I never looked back. It is fast, stable and has a lot of cool features like PHPUnit-Support or the awesome code-formatter. The symfony 1 support is good, I loved to use the command-line runner and the switching between views and controllers. The PHP support is exellent and supports PHP 5.3. But there is no special support for Symfony2 projects available at the moment. I started a feature request some month ago but there is nothing new here. For a long time there was no Twig-Support either. This can be solved by installing a Plugin but it is sometime a bit buggy and unstable.


I felt in love with PHPStorm when it was released in Version 1. It is even faster than Netbeans and has all features you need. Debugging-Support is pretty good, PHPUnit is integrated, Good Code-Formatting is available, PHP 5.3 is supported. The lookup of classes and files is fast and convinient. Twig is supported out of the box in the current stable version. All in all it is a great IDE to develop PHP-Projects. There is no special Symfony2 support at the moment. For me the great JavaScript- and CSS-Support is a big bonus, as I develop a lot of code with backbone.js and other JS-Stuff these days. PHPStorm isn’t free but available for reasonable prices. I never regret that I bought a license.


Honestly I was surprised when I checked back the PHP-/Symfony2 support of Eclipse. Two month ago I started to recheck the option to switch back to Eclipse. I was pretty surprised that there are some nice features for Symfony2 developers waiting to be discovered in Eclipse. With some additional plugins you will get a really good Symfony2-IDE. I will write a blog-post about how to setup this as soon as possible (update. Here it is: “How to build a great Eclipse-Environment for Symfony2-Development“). The highlight is definetly the Symfony2 Eclipse-Plugin. It enhance Eclipse to the most advanced Symfony2 features so far. Here are some of them:

  • Autocomplete of route-names in Twig-Templates
  • Code-Assist of Template-paths
  • Code-Assist of Container-Services
  • Annotation-Support
  • Code-Assist for translations

I still don’t like the IDE itself. It takes lang to get used to it. You have to install a lot of plugins to ge a good feature set. Most of the time you will end in a plugin hell where some plugins only work with Eclipse version x another only with version y. In the end I always had more than one Eclipse-Installations (For PHP-Development, for Java-Development, for Flex-Development…). The PHP Support in general is good but the development is done pretty much out of the view of the community.


As I blogged some time ago, PHPEdit is a capable PHP IDE. It has the most advaned symfony 1 support of any IDE on the market, but this is limited on symfony 1. There was a survey some days ago about what support for Symfony2 is needed, so the makers of PHPEdit started to work on it but there is nothing ready at the moment. Even Twig is not supported at the moment. As I’m using MAC OSX for private projects and Windows at work I need an IDE that supports both platforms. PHPEdit though is only available for Windows. PHPEdit isn’t free but the pricing is ok for what you will get.


There are other alternatives too. Some do not use fullfledged IDEs for developing. There are some really cool editors out there. I’m a long-time-user of Textmate but the development nearly stopped and the development of the Version 2 is promised for years now. It is only available on MAC OSX. The best multi-platform alternatives I found are Sublime Text 2 and redcar. Both are really cool. I like Sublime Text 2 most. As TextMate it can enhanced via Bundles, it is small and lightweight.

Lessons learned from a Symfony2 – Training session – Part 2

9. June 2011 in General, Symfony, Symfony2, workshop

Two months ago I blogged about my experiences of giving a Symfony2 training course with the PR7 release of Symfony2. The last three days I gave another in-depth Symfony2 training course, this time using beta3 / beta4. It was interessting to see how much Symfony2 has evolved over the last two month. There were improvements at every part of the Framework and the current betas made a really solid impression.

The things the attendees loved:

  • The flexibility of Symfony. It seems that is nothing you can’t do with Symfony2
  • The annotation way of developing. Having the configuration metadata of Entities and Controllers all in one place (the DocBlock of the method).
  • The maturity of the underlying concepts. You can see that all concepts are really well-thought. I wasn’t able to count the amounts of “brilliant” shouts of the attendees in these three days but there were lots of them.
  • Twig! Everybody liked Twig. Most loved: The inheritance possibility of the templates
  • Assetic. This is one of the killer features of Symfony. Assetic is really great and powerful. We faced some problems with beta3 on windows with YUICompressor. After an update to beta4 some of them seems to be fixed, others remained.
  • Doctrine: Symfony1-Users like how lightweighted Doctrine2 is. New-time users love Doctrine for the features, abstraction and Query-Language.
  • Unit-Testing: Using PHPUnit is feeling really good. The WebTestCase is a easy way to test controllers and pages.

There are still some glitches with Symfony2 that brings up

  • Long-Time Symfony1 user are missing the magic sometimes. There is a bit irritation sometimes that there is that many configuration work.
  • Because Symfony2 is moving that fast, there is the problem that some interessting Third-Party-Bundles can’t keep up with all the changes. This is a problem until we have a stable release.
  • The last betas and PRs changed a lot of syntax (take annotations for example). All these changes made sense but the problem is that there are tons of tutorials in the web that use the old ways. That is not a Symfony2 problem at all but brings up a lot of questions.
  • Documentation: The official Symfony-Documentation is getting better and better. Ryan Weaver and the others are doing a brilliant Job there, the problem is that everything that is not in the core has only little, outdated or nearly no documentation at all. Take the Assetic usage in Symfony2 for example, or the FrameworkExtraBundle. It is sometimes difficult to find the right place to start your search for information. For Symfony2-beginners it’s a challenging problem.
  • Symfony1-Users are missing the out-of-the-box behaviours of Doctrine1. Sure you can install them using the DoctrineExtraBundle but we were not able to use this Bundle with beta3.

After three days packed with Symfony2 and Doctrine-Stuff I have a very positive feeling that we are getting close to a very stable and good release of 2.0. It is pretty amazing how much more flexibility new version brings and lightweighted I feels.

As always I’m looking forward to the next Symfony2 training session.

Netbeans-Codetemplates for Symfony2

14. April 2011 in IDE, Symfony, Symfony2

As I’m working with Netbeans when developing Symfony2-Applications I created some Code Templates and Shortcuts to work more effective with Netbeans and Symfony2. If you are interessted you can download the Settingsfile and import it to your Netbeans installation. There is a Symfony 1.x and Symfony2 version available.

You can get it here:

If you miss a template just send me feedback

Using PdoSessionStorage in Symfony2

13. April 2011 in Sessions, Symfony2

Update: I wrote a more detailed cookbook for the Symfony2 documentation which is online from today: Documentation


As I told you in my last blog entry, I had the problem that there is no documentation on how to use the PdoSessionStorage in Symfony2. I opened a question on Stackoverflow but there was no one who could help me. Yesterday I found some time to investigate this problem. After reading the Symfony2 sources I found my way. So here it is:

All you need to do is to change some parameters in the app/config/config.yml file (or one of the environment dependend config-files):

    default_locale: %locale%
    lifetime:       3600
    auto_start:     true
    storage_id: pdo
    db_table: session
    db_id_col: session_id
    db_data_col: session_value
    db_time_col: session_time
  • db_table: The name of the session table in your database
  • db_id_col: The name of the id column in your session table (VARCHAR(255))
  • db_data_col: The name of the value column in your session table (TEXT or CLOB)
  • db_time_col: The name of the time column in your session table (INTEGER)

Now you have to define a PDO connection in the config.yml. For that create a new service:

        class:    PDO
            dsn:      "mysql:dbname=sf2demo"
            user:     root

That’s it :)

Lessons learned from a Symfony2 – Training session

11. April 2011 in Symfony, Symfony2, workshop

I have given my first Symfony2 training session last week. It was a bit short (two-days) but I was able to cover the basic parts of Symfony2. As I have given a lot of symfony 1 trainings in the last three years I was pretty excited how this session will work out. Everything was new, the slides, the samples and of course the framework ;) Here are some facts I learned in this two days:

The good

  1. ASP- and Java-Users love Symfony2 :) Depepency Injection, POPOs, Entity Manager. All these concepts they know can be easily used with PHP.
  2. The new WebTestCase possibilities are incredible. Everyone liked the concept of using BrowserKit and Crawler to test simple webpages. The Usage of PHPUnit instead of
  3. Twig got some positive feedback too. Some didn’t really see the positive effects in using Twig instead of PHP on first sight but after some samples a a quick glance at the possibilities of the included filters and functions most of the attendess were convinced.
  4. Doctrine2 is fast and easy to use. Java-/Hibernate-Geeks had an easy start here because of the familarity of the API
  5. Veteran-PHP programmers without framework experience liked the possibility of MVC, environments etc.
  6. The new security subframework got some very positiv feedback too. Seems a good solution for most of the people

The bad

  1. Lack of documentation at the time of training. This is obvious and predictable. The training was done with PR9 and PR10 of Symfony2. Some of the documentation is pretty good at the moment wheras some is up to none existant or useless. A configuration reference was mostly missed. There are a lot of configuration parameters buried in the depth of Symfony and it feels like no one except of the core member are know how to use them (take a look at this for example: Stackoverflow). The Form-Framework is difficult to use at the moment because of the lacking documentation
  2. Compared with symfony 1 I saw that it is more difficult to get the attendees to a point of initial understanding how a Symfony application is build and working. This is because of the lack of Convention over configuration. At the moment I’m feeling the Configuration over Convention difficult to explain.
  3. The possibility of using different ways of configuration was kind of confusing to some of the attendees. When should I use YAML, XML or annotations? Difficult to get a common understanding on this. This was even worse under the configuration possibilities are not proper documented. Doctrine is a good example here. The Annotations are described in detail but the YAML not. I’m not sure how this will work out for large development teams when some will start to use YAML others PHP…
  4. Best-Practises are missed too. This is also understandable cause ther is no stable version but I think this is something that will take some time (probably until 2.1 or even 2.2). The biggest problem: Where to put the code? Especially database oriented code.

The flexibilty of Symfony2 is incredible but I have learned the last days that this is a high hurdle to take for a lot of developers. Compared with symfony 1 I think the lack of best practises and convention over configuration is the most time consuming part of getting productive with Symfony2. The new possibilities and features of Symfony2 are awesome and it is interessting to see how good some of the existing Bundles already are.

I have two more Symfony2 trainings coming in the next months. Im excited to how Symfony2 will evolve over the time.