Category Archives: Development

Enable Twig debug in Symfony2

Posted on in Development, How-Tos, Snippets

To enable the debug tag in Twig, add the following to app/config/config_dev.yml

services:
    twig.extension.debug:
        class: Twig_Extensions_Extension_Debug
            tags:
                - { name: twig.extension }

Afterwards clear the cache and use the debug extension:

{% debug my_var %}

Sources

Check broken links/rewrites with curl

Posted on in Development, How-Tos, Linux

I just did a change in the URL structure of a bigger site and had to check if all existing URLs are rewritten correctly to the new structure. First I extracted a list of all URLs from the CMS of the old version and wrote them to a text file, each line containing an URL. Then I changed the structure and used the following shellscript to check each URL with curl and output the result. Afterwards it’s easy to analyze the results and check for broken links.

#!/bin/sh
while read f
do
  echo $f
  echo ""
  curl -IL --silent $f
  echo "------------------"
  echo ""
done < $1

Usage:

$ ./checklinks.sh links.txt > stats.txt

Continuous Integration with phpUnderControl and Git

Posted on in Development, How-Tos, Server

Continuous Integration with phpUnderControl and Git

I was looking for a decent continuous integration solution for my PHP projects for some time now, but always had the problem that most of the described solutions used SVN instead of Git as VCS system. Yesterday I found an article which describes the setup exactly as I needed it: phpUnderControl with Git on a Debian/Ubuntu system. Using the article, I managed to set up a working system quickly, which basically works as expected: CruiseControl checks the repository for modifications and starts the build process if there are any new commits. The build process includes generating API documentation (phpdocumentor), running static code analysis (php-codesniffer) and executing unit tests (phpunit). If the build succeeds, the results are published and can be accessed through a nice webinterface powered by phpUnderControl (see screenshot above which I stole from the phpUnderControl site).

However, the described setup has a few issues which bugged me:

  1. CruiseControl runs from the shellscript as root, posts all output to the console and is not automatically started at boot time.
  2. CruiseControl runs on port 8080, but I wanted to manage access to the webinterface through the apache which is already running on the box
  3. There’s no authentication – everybody can access my CI server, see the build details and start new builds through the webinterface.

Continue reading →

FH Raumbelegung: iCal Support für Wochenübersicht

Posted on in Development, Projects

FH Raumbelegung: iCal Support für Wochenübersicht

Ab sofort gibt es in meinem Raumbelegung-Webservice die Möglichkeit, die Wochenübersicht via iCal abzurufen. Dadurch lässt sich der Service komfortabel in Kalenderapplikationen (z.B. der Thunderbird-Extension Lightning) verwenden. Verwendung: einfach an eine Wochenübersicht den Parameter format/ical anhängen oder die entsprechenden Links am Ende der Übersicht verwenden.

Um zum Beispiel immer die aktuelle Woche des Studiengangs WI07 als Kalender in meinem Thunderbird anzeigen zu können, habe ich dort folgende URL als iCal-Quelle angegeben:

http://raumbelegung.stud.ailoo.net/week/show/class/wi07-vz/format/ical

Vorschläge sind wie üblich willkommen :)

Build a FlashMessenger system in ASP.NET MVC

Posted on in Development, How-Tos, Windows

Build a FlashMessenger system in ASP.NET MVC

Usually, I’m using PHP for web projects, but currently I’m working on an application using ASP.NET’s MVC framework. In many frameworks (e.g. Zend Framework or CakePHP) there is some kind of messaging system (flash messages), which allows to save a message to the session and to display it on the next request. This is useful in many situations, but mostly used after saving forms. So for example you recieve a POST request to create a new record, you save the record, redirect the user to the overview page and inform him about successful creation through a flash message which you saved before doing the redirect. As I didn’t find a way how to achieve this in ASP.NET MVC, I started to build an own solution. The result is a combination of a base controller, an action filter and a flashmessenger object which is stored in the session. Please note that I’m not too familiar neither with ASP.NET nor with C#/.NET in general, so if there are things to improve please feel free to correct me.

Continue reading →

Set up a Zend Framework application using Zend_Application (including PHPUnit setup)

Posted on in Development, How-Tos, Server

Today I spent some time setting up a new Zend Framework application using ZF 1.8.0 Beta 1 and the new component Zend_Application. Using that component, all bootstrapping is done by Zend_Application_Bootstrap and so-called resource plugins. Such resource plugins are responsible for initialization of single components such as front controller, database or the view. This way, the whole bootstrapping is nicely modularized and keeps some headache away. In addition, the majority of settings can be set in the application config file. As I ran into some issues, I’d like to note the required steps and hope that it’s useful so someone. I won’t explain the files in detail, you can find enough information about components and parameters on the manual and the quickstart, but you should get to a working setup with just copy&pasting the code here ;)

Basically a big part of this setup can be done using the new Zend_Tool CLI, however I had some problems setting it up, so I’ve done it manually (however most of the code is the one generated by Zend_Tool).

Continue reading →

NextGEN Gallery Sidebar Widget

Posted on in Development, Wordpress

Please do not post feature requests or bug reports in the comments, but file a ticket in the designated Issue Tracker instead. Thank you!

I just released a simple WordPress widget which allows you to show links to NextGEN Gallery galleries in your sidebar. For more information and download take a look at the wordpress repository.