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

Wednesday, February 15

New downgrade of php in ubuntu

Canonical has removed the repositories for karmic release so the old method to downgrade PHP stopped working, here is another way to downgrade PHP to 5.2.x

First add the PPA to your repository list

$ sudo add-apt-repository ppa:txwikinger/php5.2


if you are in Lucid then that's it, if not edit the recently added entry and change your distribution codename for lucid


$ sudo vi /etc/apt/sources.list.d/txwikinger-php5_2-oneiric.list


for example I have


deb http://ppa.launchpad.net/txwikinger/php5.2/ubuntu oneiric main
deb-src http://ppa.launchpad.net/txwikinger/php5.2/ubuntu oneiric main


and I edited to


deb http://ppa.launchpad.net/txwikinger/php5.2/ubuntu lucid main
deb-src http://ppa.launchpad.net/txwikinger/php5.2/ubuntu lucid main


Now you need to add the pinpoint for php packages


$ sudo vi /etc/apt/preferences.d/php


And put the content


Package: libapache2-mod-php5
Pin: version 5.2.10*
Pin-Priority: 991

Package: libapache2-mod-php5filter
Pin: version 5.2.10*
Pin-Priority: 991

Package: php-pear
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-cgi
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-cli
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-common
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-curl
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-dbg
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-dev
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-gd
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-gmp
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-ldap
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-mhash
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-mysql
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-odbc
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-pgsql
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-pspell
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-recode
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-snmp
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-sqlite
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-sybase
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-tidy
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-xmlrpc
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-xsl
Pin: version 5.2.10*
Pin-Priority: 991

Package: php5-mcrypt
Pin: version 5.2.6*
Pin-Priority: 991

Package: php5-imap
Pin: version 5.2.6*
Pin-Priority: 991


Now it's time to update the pachage list


$ sudo apt-get update


Everything should run without errors or warnings, now install PHP 5.2


sudo apt-get install php-pear php5-dev php5-gd php5-mysql php5-sqlite libapache2-mod-php5