havvg's playground

Developing Software is Fun!

Symfony: How to Bundle

Toni Uebernickel
Creating a bundle for Symfony is one of the most misunderstood topics. This topic is very old, but it got some tension in the recent past. I’ve been discussing this topic with several people using different channels for more than three years now. There are some blog postings out there...

How to extend form fields in Symfony2.1 using extensions

Toni Uebernickel
The previous post on FormTypeExtensionInterface is outdated for the current Symfony version 2.1. As requested multiple times, I want to share an updated version on how to create such an extension. The only main differences between the previous posts state and the current version are: The extensions are now using...

An example of Symfony2 CollectionType form field prototype

Toni Uebernickel
While working an a multi-step form with multiple CollectionType in it, I came across the issue requiring a generic solution for handling allow_add and allow_delete on a collection. As there is no entry on the allow_delete part in the Symfony2 documentation itself, this solution may not be the best way...

Validate emails on redirects in Symfony2 with Behat

Toni Uebernickel
Contexts Before we can actually start, we need some more step definitions. As we follow DRY(“Don’t Repeat Yourself”), we are going to use Behat\CommonContexts. There are several Contexts given, we can make use of. In particular we need two of them. The MinkRedirectContext for the redirects and SymfonyMailerContext to verify...

git rebase is not a lion, it's a cat - Part Two

Toni Uebernickel
In the previous post we took a look at the basics of git rebase The most important part we will take a deeper look in this part: The history will be re-written. As mentioned in the previous post, this is not necessarily a bad thing. To have a greater view,...

git rebase is not a lion, it's a cat - Part One

Toni Uebernickel
There are many users out there being scared to use git rebase. To wrap things up, git rebase is not a lion that will hunt you down. It is a cat, it likes you, until you do something fancy and will hurt you once. You will know how to deal...

Merging a git subtree on failing path guessing

Toni Uebernickel
If you don’t know how to set up projects using a git subtree look at the previous post. I set up a similar project, in order to make it easier to post, I will wrap up the repositories: “landingpages” is a web application for managing product landing pages to attract...

Using git-subtree: Example adding Symfony2 bundle on cloudControl

Toni Uebernickel
If you don’t have, imagine: You have got two applications built on Symfony2. Both of those applications are deployed on cloudControl. Both applications share one or more bundles you have written. All repositories are closed-source (Yes, those exist!). The Setup We got our first application on the remote repository git@git.localdomain:application-a.git....

How to extend form fields in Symfony2 using extensions

Toni Uebernickel
Update: For Symfony2.1 update please take a look at the updated post. In case you have read the form documentation, you will have noticed, that the example won’t work out of the box. {% block field_widget %} {{ block('base_field_widget') }} {% if help is defined %} <span class="help">{{ help }}</span>...

Github:Pages with Jekyll

Toni Uebernickel
Finally, my blog is now on github:pages! Making this decision has its root long time ago. I didn’t want to use Wordpress anymore. It’s too much secondary work for me like updating the installed software, maintaining broken plugins, fixing stylesheets for special purposes and so on. Since then I wanted...

Behavior Driven Development in Symfony2 with Behat, Mink and Zombie.js

Toni Uebernickel
Long time no post, but now it’s time for a new one. I wrote a guide on behavior driven development in Symfony2. It’s meant for beginners and designed “from scratch”. This guide caught some attention and made it into the official Behat documentation as a cookbook entry. If you have...

How to combine git and cloudControl using github

Toni Uebernickel
Requirements This is the list of requirements to get this tutorial done. a working cloudControl account an active github account cctrlapp installed git installed UNIX based operating system There are plenty of tutorials how to get these things up, so we skip it here completely. The environment – What do...

Rackspace Cloud Servers

Toni Uebernickel
I moved my servers into “The Cloud”™ - more specifically the Rackspace Cloud. Well why did I do this? The answer is about two years old. I asked my previous hosting service whether they are able to migrate my virtual servers to instances of their “root servers”. They said, this...

CruiseControl git modificationset errors

Toni Uebernickel
I encountered some errors while configuring my phpUnderControl. One of the errors were the <git> <modificationset> not returning results, but the gitbootstrapper actually updated the git repository. In my case, this was because the user running CruiseControl has set up colorful output in its git config. This option changes the...

speed up PHPUnit CodeCoverage in symfony projects

Toni Uebernickel
Well, PHPUnit CodeCoverage is pretty nice and exports some nice HTML files to take a look into. However, a project most often contains more than just PHP files and for a symfony project this could be the phpunit.xml.dist. It removes all folders from your coverage report, that most likely are...

config.xml and build.xml for phpUnderControl building a symfony project hosted on github

Toni Uebernickel
Well yesterday I moved to PHPUnit and I just felt the way I want to use phpUnderControl as continuous integration server. The installation part was the easiest one, gathering all the information spread among several websites was not that easy. Especially for me not having used CruiseControl either. I don’t...

add a project wide TestCase to sfPHPUnit2Plugin

Toni Uebernickel
I just moved my projects from lime to PHPUnit testing framework. To make this easier, I appreciate the work of Frank Stelzer, who has created a plugin which makes this move pretty easy within symfony. Setting things up was one easy task, but soon I ran into the problem not...

git checkout name in bash primary prompt

Toni Uebernickel
You want to have an overview of your current git checkout in your bash prompt? Then read on! parse_git_branch () { git name-rev HEAD 2> /dev/null | sed -e 's/\^0$//' | sed 's#HEAD\ \(.*\)# (\1)#' } BLACK="\[\033[0;38m\]" RED="\[\033[0;31m\]" RED_BOLD="\[\033[01;31m\]" BLUE="\[\033[01;34m\]" GREEN="\[\033[0;32m\]" export PS1="$BLACK\u@\h:$GREEN\w$RED_BOLD\$(parse_git_branch)$BLACK \$ " Here some explanation, on what’s...

jQuery qTip applies two times after adding objects to the DOM

Toni Uebernickel
At Adcloud we are using the jQuery qTip plugin, which provides pretty nice and easy to apply tooltips. We ran into one small problem, which solution I want to share. The tooltips work fine, except when you are adding new objects to the DOM. As of jQuery 1.4 there is...

ORM Designer

Toni Uebernickel
I were asked to take a look into ORM Designer by Inventic s.r.o. two weeks ago. I tested the software and here is my little piece of review as a developer. Disclaimer Everything I am talking about is related to the usage of ORM Designer for symfony with Propel. Design...

jQuery lightBox with multiple galleries on one page

Toni Uebernickel
Lightbox is one great plugin for jQuery. As there is no option to set up relations for links of images to generate galleries of it like thickbox does, you have to call lightBox multiple times to get your galleries up and separated from each other. A simple call for lightBox...

couchdb on ubuntu Karmic Koala

Toni Uebernickel
Connection refused I need couchdb 0.10.0 as it provides JSONP support, so I installed the bleeding edge ubuntu Karmic Koala development branch, which ships couchdb 0.10.0. But when doing a simple curl request on the couchdb server, the connection was refused. $ curl -vX GET https://127.0.0.1:5984 * About to connect()...

Parallels 3.0 on Snow Leopard

Toni Uebernickel
I upgraded to Snow Leopard on my Mac and as described on Apple’s website Parallels 3.0 won’t start on Snow Leopard. At least not by default. However it is possible to start Parallels 3.0 under Snow Leopard without updating anything. As there are some good reasons given, that lead to...

adding actions to a plugins module in symfony

Toni Uebernickel
There are many cases in which you might want to extend capabilities of a plugin. As this is not that complicated at all and you can go edit every file within your plugin directory, this is not the best way doing this. Adding new methods to a library can easily...

share user class among apps within one symfony project

Toni Uebernickel
Is it possible to share one user class among all apps within one symfony project? - Yes, it is! It is very easy, too. All you need is - surprisingly - a class, some changes in the factories.yml of the apps sharing the user class and that’s it! At first...

triggerHandler on live event bindings in jQuery

Toni Uebernickel
As stated in the jQuery API Documentation, the triggerHandler() method does not work on events bound to objects using the live() method, which includes also objects created after the DOM was loaded completely. However, this is nothing unusual. In fact, it might be a common way to work within an...

enable submit event on live bindings in jQuery

Toni Uebernickel
The live() method is one great new feature of jQuery 1.3, however it does not support binding of the event ‘submit’ of forms. $('form').live('submit', function() { // your callback }); This can be simulated by a simple workaround on the selected objects. The click() event can be bound using the...

single table inheritance pattern in symfony using propel

Toni Uebernickel
Rails is doing it, Java is doing it very similar, you can do it in symfony, too: make use of the Single Table Inheritance pattern. What’s STI? Wikipedia, the free encyclopedia: Single table inheritance is a way to emulate object-oriented inheritance in a relational database. Let’s say you got two...

dynamic values in forms with symfony

Toni Uebernickel
Let’s imagine you have a form set up and want to add some dynamic values to the object being saved by this form after the form has been submitted by the visitor. The example model (wspNopasteEntry) below has a property created_by which refers to a sfGuardUser (or anonymous). So, at...

using Last-Modified HTTP Header in symfony

Toni Uebernickel
As there are many situations in which you might want to use the HTTP status code “304 - Not Modified” symfony gives you an easy way in doing so. Especially while you are delivering dynamic content, it might not be that easy to determ whether the request has been modified...

multiple applications in symfony using subdomains

Toni Uebernickel
You might have thought about it - me too :) It’s one simple way to use subdomains to manage the chosen application of your symfony project. <?php require_once(dirname(__FILE__).'/../config/ProjectConfiguration.class.php'); switch ($_SERVER['HTTP_HOST']) { case 'backend.megacomplex.de': $configuration = ProjectConfiguration::getApplicationConfiguration( 'backend', 'prod', false); break; case 'mkt.megacomplex.de': $configuration = ProjectConfiguration::getApplicationConfiguration( 'mkt', 'prod', false); break; case...

unit test with sfPropel*BehaviorPlugin in symfony

Toni Uebernickel
Today I have written my first unit test in symfony in which one of the models has attached a propel behavior. In my case it was the sfPropelActAsSluggableBehavior. While writing the unit test I didn’t thought it would be a problem, until I finnaly ran the test. The error message...

PHP: Wake On LAN (WOL)

Toni Uebernickel
Ich habe neben meinem Macbook natürlich auch einen Desktoprechner. Dieser läuft natürlich nicht den ganzen Tag durch, wer sollte auch die Stromkosten dafür aufbringen :). Dennoch wär es hilfreich, wenn ich den Rechner einfach hochfahren könnte - von überall. Die Technik dazu ist nichts Neues und trägt den passenden Namen...

Tutorial: Fenster an Hilfslinien ausrichten

Toni Uebernickel
Wer kennt es nicht? In heutigen Anwendungen wird es dem Benutzer immer einfacher gemacht, Ordnung zu halten. Einen kleinen aber feinen Beitrag leisten sogenannte Hilfslinien. Anwendungen, die mit mehreren Objekten arbeiten, nutzen diese Hilfslinien unter Anderem auch, um die Objekte zueinander auszurichten. Ich hab heute für das AzSMRC webUI genau...

iTunes: mp3 in iPhone Klingelton konvertieren

Toni Uebernickel
Ich habe nun einige Webseiten durchsucht und habe auch eine Lösung gefunden. Natürlich kann man seine eigenen mp3s in Klingeltöne umwandeln. How To: mp3 to iPhone ringtone Wie man das nun genau macht, wird auf vielen Internetseiten beschrieben. Hier der generelle Ablauf im Kurzen. Rechtsklick auf die mp3 in iTunes...