Ressources documentaires pour Mandriva Linux et les Logiciels Libres

Billets libellés php

Netbeans : my new PHP IDE of choice

During a longPHP support dans Netbeans time my PHP development of choice was and the PHP plugin for Eclipse : Please note that there’s another PHP plugin for Eclipse developped by Zend and IBM : also known as the PHP Development Project. However I was mostly using Eclipse and phpeclipse as it was the first PHP plugin I used, and I did appreciate the native integration of CVS and team management tools.

However tonight I decide to give a try to Netbeans with PHP support. What can I say ? I just fall in love. Whereas I have to be used to the new syntax highlighting, PHP support in Netbeans is top for several reasons :

  • Netbeans seems to start faster than Eclipse and can also import Eclipse projects,
  • it support project creation from Zend or Symphony frameworks ( even if I don’t use them ),
  • it supports natively and easily PHP debugging ( with xdebug ) and PHPUnit/Selenium tests,
  • It allows Code Coverage,
  • It correctly support and parsed my CSS files or .sql files,
  • Even better … It allows to connect to your database, view its schema, table structures, and of course execute queries and test your migration SQL scripts,
  • it allows to search through a plugin directly in the PHP manual
  • it can dynamically parsed and handle your PHPDoc tags and then present your PHP file structure with the PHPDoc you add : this is a good insensitive to write correct PHPDoc,
  • Last but not least it provides native CVS and Mercurial integration

In only a few clicks I add way more features than with Eclipse and PHPEclipse. Whereas it’s possible to add xdebug support to eclipse and phpeclipse, the process is not automatic and can be somewhat hard. So finally I switched to Netbeans for my PHP dev. The procedure is very straightforward under Mandriva 2010 Spring as Netbeans packages is already available. Here is the procedure, under Mandriva 2010 Spring, to install Netbeans with a useful and complete PHP development environment :

  1. install the Netbeans 6.8 and its related packages with urpmi : [bash light= »yes »]urpmi netbeans[/bash]
  2. install PHPUnit, xdebug and Selenium : [bash light= »yes »]urpmi php-pear-PHPUnit php-xdebug php-pear-Testing_Selenium[/bash]
  3. restart Apache to activate the PHP extensions : [bash light= »yes »]service httpd restart[/bash]
  4. Now start Netbeans from the menu : Application -> Development -> Development Environment -> Netbeans IDE 6.8
  5. Once Netbeans have started, deline if you wish the registration, and then select on the right pane « Install Plugins« . Here is the list of plugins I did choose for my PHP development : Database, PHP, Php Manual Search, Selenium module for PHP. Installing plugins is very easy, just select them, and then follow the instructions ( most of the time hiting Next or validating a License ). Don’t forget to accept Php Manual and thus even if the plugin is considered as not trusted.
  6. Once your plugins have been installed, restart Netbeans. You may want to decline sending informations about you to Netbeans team.

Now you can import your old Eclipse projects, or if as me you are using a control version system, just checkout your repository ( Team -> CVS -> Checkout ). Mercurial and subversion are supported. For those willing to have Git support, they should have a look at the third party plugin : Netbeans Git Plugin ( homepage : Netbeans Git Module ). To add third parties plugins, download them as .nbm file, then install them with Tools -> Plugins -> [Downloaded] tab -> Add Plugins.

There’s one big caveat however :  Netbeans internal SSH client doesn’t support key authentification. You will have to use password authentification, or create a SSH tunnel. For further informations see

And now happy PHP coding with Netbeans 🙂

eZ Components under Mandriva

Since some months, I’m using eZ Components for the intranet of my society. I’m specifically using the Graph component which allow to produce some very beautiful graphs, especially when using the SVG or the Cairo output driver.
At the beginning, I installed eZ Components by using the big tar.bz2 package which contains all the component plus the documentation and the regression tests. This was very big. The best way to install eZ Components and ease its maintenance if your distribution is not providing the packages is to use PEAR. So here is the way to install eZ Components by using PEAR on Mandriva. However this HOWTO may apply to others distributions.

  1. You need to have a working PHP+Apache stack : For this you may use the task-lamp-php metapackage which will install a working Apache + PHP + PEAR setup : [bash light= »1″]urpmi task-lamp-php[/bash]

    As you may noticed, this will install MySQL support. If you’d rather have PostgreSQL support, you just need to install the php-pgsql package.

  2. Install the needed requirements for the eZ Components : Each eZ Components have some requirements on some PHP extensions. You can consult the requirements on the eZ Components requirements page. For all components, you need pcre, reflection and spl support in PHP. Theses supports are available by default in the Mandriva PHP package. The Graph component require for example dom and xml support, and eventually gd support if you want to generate JPG/PNG images. To install the needed requirements, you just need to install the corresponding PHP packages which consist on the PHP extension name prefixed by php- : [bash light= »1″]urpmi php-xml php-dom[/bash]

    . If you want to generate graphics by using the Flash output, you need to install also php-ming. For high quality PNG graphics, you will have to install PHP cairo wrapper. Unfortunately as this package is not bundled in Mandriva, you will have to compile it and install it manually. For this please follow my previous about installation of PHP cairo wrapper under Mandriva

  3. Restart Apache to load PHP extensions : In order to activate the newPHP extension, you need to restart Apache : [bash light= »1″]service httpd restart[/bash]
  4. Add eZ Components PEAR channel : [bash light= »1″]pear channel-discover[/bash]
  5. Install the wanted eZ Components : Now you can easily the components you want to use by using PEAR. For example to install the Graph component you just need to do : [bash light= »1″]pear install ezc/Graph[/bash]

    . If at the contrary you want to install all the eZ Components, then you will use the following commande instead :

    [bash light= »1″]pear install -a ezc/eZComponents[/bash]

  6. Updates handling : To updates the components, you just need to replace install by upgrade in the PEAR command. For example to update the Graph component to a newer version, you will use : [bash light= »1″]pear upgrade ezc/Graph[/bash]

    . People who install the full eZ Components may want to use instead : pear upgrade ezc/eZComponents[/bash]

  7. Add eZ Components support in your PHP script : Adding eZ Components support in your PHP script is easy. On Mandriva, PEAR packages are in the default include/require PATH, so you just need to add the following lines at the top of your PHP scripts to be able to load automatically the different components on demand :
      spl_autoload_register( array( 'ezcBase', 'autoload' ) );

As you can see, adding eZ Components support in your PHP application is easy, and many components may be useful. In some further HOWTO, we will see how to use the graph components by using a wrapper function. However don’t hesitate to consult the well-written eZ Components documentation.


My Tweets