Oops!... I did it again. I bought a new computer. Actually, a new old computer. A great IBM Thinkpad R40 2681. Ubuntu 13.10 Server runs pretty good (the first boot after shutdown generates a kernel panic, but the second boot is always ok). The interesting part of this short story is the BIOS upgrade process I followed. Since I removed Microsoft Windows as soon as I could, I was unable to follow the standard upgrade process so I began searching other ways to do it. I found a very good how-to on thinkwiki.org. The idea is to prepare a USB flash drive with Grub4DOS and let Grub load the DOS boot image extracted from the ThinkPad BIOS update diskette .exe file. The DOS boot image contains the IBM Thinkpad System Program Service Utility that will guide the user through the upgrade process. Just one note, I had to partition the USB drive using parted before being able to install Grub on the Master Boot Record of the drive.

Some links:

Some screenshots:

Grub4DOS boot screenshot

IBM Thinkpad R40 BIOS update screenshot

IBM Thinkpad R40 BIOS update warning screenshot

Cover of A Year With Symfony by Matthias Noback

A Year With Symfony is a great book written by Matthias Noback on... well... the Symfony2 framework. Actually that's only half true. The book is full of "best practices" applicable to all kinds of projects and frameworks.

Matthias starts by describing how a basic request is handled by Symfony. From the Kernel to the response, everything is described in a detailed and clear way. Then patterns of dependency injection get on stage. Knowing how to create services and how to manage their dependency will make you love this part even if you are not developing with Symfony2. Matthias continues showing how a project should be structured. Also this part is focalized on Symfony2 but you'll be able to apply this knowledge to anything. Then the focus turns on configuration and security. The security part is very detailed and it should be "studied" more than once. The last part is titled "Being a Symfony developer" but it makes you understand how important it is to know how a framework (any framework you are using) works so that the code you're writing can be used by others and adapted to different projects.

Personally, I've chosen to buy the book because I had some trouble understanding and memorizing some Symfony2 stuff and I can assure you it really helped me.

You can buy Year With Symfony in digital via Leanpub or you can get a printed copy via Lulu. I also recommend to subscribe to Matthias Noback's blog on Symfony.

Snapshot of Apigility composer.json

For a new project I needed to publish messages on Twitter via Twitter REST API. Since I'm a Zend Framework fan, I choose to give ZendService\Twitter client a try.

I started by running php composer.phar install using a simple composer.json file:

{
    "require": {
        "zendframework/zendservice-twitter": "2.1.0"
    }
}

The library got downloaded and I was able to test my PHP script doing some "copy & paste" from the documentation:

include "vendor/autoload.php";

$config = array(
    'access_token' => array(
        'token'  => 'TOKEN',
        'secret' => 'SECRET',
    ),
    'oauth_options' => array(
        'consumerKey' => 'CONSUMER_KEY',
        'consumerSecret' => 'CONSUMER_SECRET',
    ),
    'http_client_options' => array(
        'adapter' => 'Zend\Http\Client\Adapter\Curl',
        'curloptions' => array(
            CURLOPT_SSL_VERIFYHOST => false,
            CURLOPT_SSL_VERIFYPEER => false,
        ),
    ),
);

$twitter = new \ZendService\Twitter\Twitter($config);

$response = $twitter->search->tweets('#zf2');
$tweets = $response->statuses;
var_dump($tweets);

But as result I got a fatal error:

PHP Fatal error:  Call to a member function connect() on a non-object 
in /Users/me/Development/zf2-twitter-test/vendor/zendframework/zend-http/Zend/Http/Client.php on line 1359

To make a long story short I found out that the ZendOAuth\Client::getAdapter() method wasn't confirm to the parent class. So I forked https://github.com/zendframework/ZendOAuth, changed the code to what I think it's a solution to the problem, committed and finally synced to my dev-master branch. At this point I modified my local composer.json adding my git repository and specifying the dev-master branch for zendframework/zendoauth:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/lorenzoferrarajr/ZendOAuth.git"
        }
    ],
    "require": {
        "zendframework/zendoauth": "dev-master",
        "zendframework/zendservice-twitter": "2.1.0"
    }
}

After running php composer.phar update all started working great.

This post should make you interested in trying Zend Service Twitter.

Cover of Signaling PHP by Cal Evans

If you make a living out of PHP you probably aren't coding just for the web.

Sometimes we need to do complex things, like queries that generate huge reports, and the browser is not the best way to go. That's when we write scripts made to be run in a terminal.

Some of us just type php see-you-later.php at the command line and stay there waiting for the process to end. Others maybe use something like echo "I'm alive!\n"; to make sure the script is still doing something. Some times we need to stop the execution but we're too scared to press the CTRL+C combination because we just don't know where the script is going to stop!

Cal Evans in Signaling PHP shows us how to use signals in PHP CLI (Command Line Interface) applications to correctly stop execution of a running script and schedule and manage alarms. The book shows a different perspective on how to interact with PHP CLI scripts in a more clean and efficient way.

Signaling PHP is perfect for the busy guys. You won't need to go searching the PHP documentation or Google to understand how things work. Buy it, read it, and you'll be able to do a lot more than Cal Evans shows you.

You can buy the book via Leanpub or searching "Signaling PHP" on Amazon.

Recently I needed to migrate a WordPress website from a shared hosting provider to to a virtual private server. More than 4GB of data to transfer to my computer and to re-upload to the new server. So I started looking for a way to do a recursive FTP download directly on the new server.

I first tried to use wget:

wget -N -r --ftp-user=USERNAME --ftp-password=PASSWORD ftp://ftp.example.com/com.example/

but wget wasn't able to download all the files, the ones under the com.example/wp-content/blogs.dir/ (all the subdirectories were there but no files).

So I tried the less common lftp:

lftp -u USERNAME,PASSWORD -e 'mirror /com.example/' ftp.example.com

lftp was able to download everything, also .htaccess files. This is the official lftp website: http://lftp.yar.ru/