Thursday, December 5

Installing a git server on ubuntu 13.10

Now it's simpler than ever before ...

First you'll need to have a ssh key, if you don't have one generate it with

$ ssh-keygen

The defaults are fine for the test

Now install the server

$ sudo apt-get install git-core gitolite

After this a wizard will popup asking for:

  1. The git user, by default gitolite (the user that gets the code)
  2. The public ssh key for the admin, or the path to it, you can use the previously generated key located in ~/.ssh/id_rsa.pub if you left all the defaults
And that's it ... I couldn't believe it, last time took me one afternoon to install the server

Now to configure the repositories you need to clone the gitolite admin


$ git clone [user you selected on the first step of the wizard]@localhost:gitolite-admin

in my case 

$ git clone gitolite@localhost:gitolite-admin





Wednesday, December 4

Configuring Jenkins to act as continuous integration server for PHP [WIP]

First install Jenkins, fortunately it's available in Ubuntu's repositories

$ sudo apt-get install jenkins

By default jenkins runs on port 8080, so if you don't have anything in conflict with that port just pointing your browser to http://localhost:8080 will pop up your jenkins installation




Now we need something to allow Jenkins to execute the unit tests in our code, the most used is PHPUnit, also at the repositories

$ sudo apt-get install phpunit

Jenkins relies on ant to build the code, in fact it is installed as a dependency, so the next thing to do is to write an ant configuration file called build.xml at the application's root

As an example this minimal configuration based on a template found in jenkins site:





Creates a project with several targets, each target can be called using ant like

$ ant target

The main target is build, which cleans the build directory and then executes phpunit, to test it simply type

$ ant build

As you can see phpunit is being called without any parameters, so it relies on it's own xml configuration file named phpunit.xml.dist (not sure if the dist is required) but it works :D

A sample content can be



basically creates a test suite and searches for all files ending in Test.php (like ControllerTest.php) in the specified directories

The logging section allows phpunit to write code coverage metrics and junit reports that jenkins can read

The filter section prevents the execution of the classloader.php since it's our bootstrap for the unit tests

With this file ant has everything to run the build, now moving to jenkins to wrap everything up




Monday, September 10

Netbeans and PHPUnit again ...

Well in Ubuntu 12.04 the steps to install PHPUnit had changed a bit ...

Install the latest PHPUnit with ant

I got this instructions from a blog, but searching I cannot find which one ... anyway, the last steps seems redundant but this will ensure that the correct version of PHPUnit is installed

$ sudo apt-get install ant php5-dev php-pear
$ sudo pear channel-discover pear.phpunit.de
$ sudo pear channel-discover pear.symfony-project.com
$ sudo pear channel-discover components.ez.no
$ sudo pear update-channels
$ sudo pear upgrade-all
$ sudo pear install --alldeps phpunit/PHPUnit
$ sudo pear install PhpDocumentor


Now we need to install PHPUnit from the repositories, this will create the phpunit file in /usr/bin, I'm sure there is a better way for this but I did't had the time to check

$ sudo apt-get install phpunit

The last step broke phpunit, so we need to reinstall it ...

$ sudo pear uninstall phpunit/PHPUnit
$ sudo pear install phpunit/PHPUnit 

Make work PHPUnit with Netbeans again

Open the Netbeans preferences, go to the "PHP" tab and in that tab select the "Unit Testing" tab
Type /usr/bin/phpunit into the first box, click "OK"


Now at your project right click the "Include Path" and select the "properties"

Click "Add Folder .,." and select the folder /usr/share/php/PHPUnit Click "OK"


Now you will have the autocomplete running for abstract classes, methods, asserts, etc.



As always pressing alt + F6 the unit tests will run in Netbeans providing a useful output and code coverage


Sunday, September 2

12+ Must have apps for LAMP development

Now that I am moving to a new job I need to install again my computer, so here is a list of applications that are often needed in a LAMP environment

1. Choose the right Linux distribution

I've always been a fan to ubuntu, but the latest releases of ubuntu are far to buggy and unstable, so I ended up switching to Linux Mint, the reasons are many, the ia32libs are not broken, it has java out of the box, not Oracle's but still ... in any case ane distribution you feel comfortable is fine.

2 Choose your desktop environment

Linux is vast and any desktop environment has it's unique features, my option on this is Gnome Shell available in the repositories, if not using gnome usually KDE is my next option

$ sudo apt-get install gnome-shell gnome-session



3. Choose your IDE

This is a controversial point, I often have many IDEs to code, my favorite is becoming PHPStorm, followed by NetBeans, Eclipse and Aptana, also have Komodo in the installers just in case.
When switching to android Eclipse is pretty much the best option


4. Web Browser

A nice web browser is key to productivity, my choices are simple Chrome / Chromium or Firefox with firebug, I got more used to Chrome altrough Chromium is on the repositories and firefox is almost always pre-installed

$ sudo apt-get install chromium-browser




5. Color Picker

Even working with backend sometimes is needed to grab a color from a design, here comes Gpick, a small utility that is in the Mint repositories that gives the HEX value of any pixel in the screen, reminds me of the old days using InstantEyeDropper in windows

$ apt-get install gpick


6. Screenshot tool

It's always needed a good tool to take screenshots, Gimp has this feature but I found Shutter to be one of the best options available, it is available on the repositories

$ sudo apt-get install shutter



7. Image Editor

A good image editor is always needed, the support for psd files and low memory consuption makes Gimp the best choice even when I had some serious issues reading psds created by Adobe Photoshop specially in the layers, so make sure you use this tool with caution

$ sudo apt-get install gimp



8. Database E-R Tool

A tool to see the E-R diagram of a database is really important, specially when defining a new database or reverse engineering an old one, MySql Workbench has proven to me many times even with it's bugs

$ sudo apt-get install mysql-workbench



9. File synchronization

Often I send myself unfinished code that would break the code in the version control, for this situations the cloud storage is the best solution, Dropbox has a native application, Box and Google Drive can be easily mounted using Nautilus and Secure WebDAV so the coice is yours, I use more Dropbox since the application is better for android

10. Virtualization

There are many options here, my favorite is Virtualbox, is easy to install and it behaves consistently with the hosted operative systems


11. SSH manager

I have access to many servers, dev, staging. produccion, several clients ... and sometimes is difficult to keep track of all the passwords and servers available I found a few solutions here but the one most rewarding was Gnome Connection Manager

12. Remote management

Sometimes I had to left the PC at work on, so to handle it remotely I found that Team Viewer is the best solution, it works even if a public IP is not available and the android app is very decent

Extra, Gnome Shell Extensions

If you choose to use gnome shell, there are some very interesting extensions available online, from themes to pomodoro clocks, just take a look into the directory and pick the ones you want

Wednesday, February 29

Installing ImageMagick for PHP after the downgrade

Sadly the ppa repository does not have lots of packages, one of the best for image treatment is imagemagick, first we need to install the dependencies

$ sudo apt-get install php-pear imagemagick php5-dev libmagickwand-dev


Then all we need to do is install the extension using pecl

$ sudo pecl install --alldeps imagick


Now we need to add the image magick library to php, create the file imagick.ini

$ sudo vi /etc/php5/conf.d/imagick.ini


And put this code

extension=imagick.so


save the file and see if the extension gets loaded

$ php -m | grep imagick


also, don't forget to restart apache
$ sudo service apache2 restart