Archive for 'Devel'

Running Phing from NetBeans

I use NetBeans to write PHP code. One of my biggest concern was the inability to launch external shell scripts without leaving NB. I came up with a hack a few months ago, but it was a HACK… up until yesterday.

I discovered Command-shortcuts, an awesome NB plugin. It lets you launch any external command from NB. It also lets you pass a #{file} argument, so the command can operate on the file at hand.

The only problem was the inability to launch a command and pass it the base directory of the project. Command-shortcuts has a #{mainproject} parameter, but you need to define the project you are working on as a main project in NetBeans (seems like you need to do it every time you open the project – a sure way to waste time finding why it doesn’t work).

So i wrote a simple helper script to find the project base directory and invoke the Phing buildfile in that directory.

#!/usr/bin/php -q

$logfile = sprintf('/tmp/nbphing_helper.%d.log', getmypid());

if (! isset($argv[1])) {
    file_put_contents($logfile, "\n  No file specified\n\n");

if (! is_readable($argv[1])) {
    file_put_contents($logfile, "\n  File not found\n\n");

if (! isset($argv[2])) {
    file_put_contents($logfile, "\n  No target specified\n\n");

$search = $argv[1];
do {
    $search = dirname($search);
} while(! is_readable(sprintf('%s/build.xml', $search)) && strlen($search) > 2);

if (! is_readable(sprintf('%s/build.xml', $search))) {
    file_put_contents($logfile, "\n  build.xml not found\n\n");

exec('phing ' . $argv[2], $output);
file_put_contents($logfile, implode("\n", $output));

function bailout($logfile) {
    exec('konsole -e less -r '.$logfile);

It’s a dirty hack, but I can now invoke several phing build targets without leaving the IDE.

Any suggestion, improvement, criticism is welcome!

PHP is the most widely used language for web application development. In spite of this, nobody uses PHP to develop desktop apps. I suppose one of the main problems is the lack of an easy to install, prebuilt package. There were only a few win32 binary releases, and each of them was released after a long period of silence. This is not a criticism to php-gtk developers (a BIG THANK to everyone involved), but users always had the feeling of a dead project.

The real problem is the lack of enough developers, packagers, doc-writers, so I decided to contribute some documentation to build php-gtk on Windows.

It took me a few weeks and the recipe is very long and tedious. But it should be repeatable. The recipe for PHP 5.3 is on Github, so everyone can contribute to improve it.

Symfony2: the big picture

I started playing with Symfony2 when it was in beta. The biggest obstacle in my learning process was the lack of an architectural overview; something that would describe the flow of execution of every request, at least at a very coarse grain. I tried to read the official docs and various articles on the Net: I was able to do things but didn’t know how (and why) they worked – when they did. The immediate consequence was that I was almost always unable to adapt the examples to my specific needs.

Continue reading…

Phing e NetBeans

Come strumento di build/deploy per NetBeans, l’unica opzione è ant, tramite l’apposito plugin.

Per motivi che ignoro, sembra che a nessuno sia venuto in mente di realizzare un plugin per NetBeans che permetta di eseguire comandi shell qualsiasi. Figuriamoci se qualcuno possa aver fatto un plugin per Phing.

Dovendo fare di necessità virtù, ho riadattato un hack dal blog “My toy page”.

Continue reading…

TreeGrid with ExtJS 4

ExtJS has a lot of components to rapidly develop powerful web applications.
A few days back, I was faced with the need to display hierarchical data extracted from a database. I looked at several alternatives, but none of them was so full-featured and well-integrated as ExtJS is. So I developed a prototype to learn the basics of ExtJS 4 TreeGrid component.

Continue reading…

Closures bring concise and elegant solutions to a wide array of coding problems. A common use is in array operations; array_map(), array_filter() and similar functions all can take advantage of Closure expressiveness and elegance.

Before PHP 5.3 the same functionality could be implemented with callback functions or “manually” iterating over the arrays. I’m currently developing an application that manipulates large arrays and soon started speculating about which is the fastest approach.
Continue reading…

PhpDay 2011

È passato un anno senza scrivere niente: shame on me! Vista l’ottima impressione dell’anno scorso, quest’anno mi sono sobbarcato i 500Km necessari per il mio secondo phpDay. Tanta bella gente e un keynote davvero “storico” di Jacopo Romei.

Continue reading…

PhpDay: the day after

2 giorni al PhpDay 2010 (venerdì e sabato) assolutamente utili; forse era opportuno andare anche al giovedì. Location un po’ naive ma in vantaggio non c’erano problemi di traffico e parcheggio; connessione Internet veloce e… a lot of smart people.

Oggi ho migrato una buona parte del codice Javascript di da Prototype a jQuery. La migrazione è stata abbastanza rapida ed indolore e mi ha permesso di fare un minimo di esperienza con jQuery.

Devo ammettere che il grande fermento intorno a questa libreria mi sembra giustificato. Il codice migrato fa cose abbastanza semplici e non ci sono state sfide tecniche interessanti, ma il risultato è senz’altro buono;

Continue reading…

IE7 peggio del 5?

Non è facile, ma IE7 ce la sta mettendo tutta per conquistare la palma di peggior browser di casa Microsoft.
Ecco lo scenario:

  • Form con 250
    &lt;input type="text"&gt;

    e 500

    &lt;input type="button"&gt;


  • Prototype e 1.8.1;

richiede circa una decina di secondi su un Core2 ben carrozzato e altrettanti ne richiede


Lo stesso codice, sullo stesso PC ma con Firefox 3 viene eseguito entro un tempo non percettibile dall’utente. Ci ho messo una pezza, assolutamente antiestetica e ora il risultato è accettabile anche su IE7; se questo è il browser che doveva correggere tutti i problemi di IE6, aspetto la versione 8 come si aspetta l’esattore delle tasse.

Ho sempre avuto un pregiudizio verso IE7 e i fatti cominciano a dimostrare che la sensazione a pelle era giusta.