Fix “Configuration of pmadb… not OK” in phpMyAdmin

You may get this message in pmpMyAdmin:


To fix this you have to import/create the phpmyadmin database with it’s tables. An SQL script called create_tables.sql should be in the scripts or examples folder of your phpMyAdmin installation. Run it and then create a user called pma and give it permissions to the phpmyadmin database:

CREATE USER 'pma'@'localhost' IDENTIFIED BY 'pmapass';
GRANT ALL PRIVILEGES ON `phpmyadmin`.* TO 'pma'@'localhost' WITH GRANT OPTION;

Now edit and configure/uncomment those lines:

 * phpMyAdmin configuration storage settings.

/* User used to manipulate with storage */
$cfg['Servers'][$i]['controlhost'] = 'localhost';
// $cfg['Servers'][$i]['controlport'] = '';
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = 'pmapass';

/* Storage database and tables */
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
$cfg['Servers'][$i]['relation'] = 'pma__relation';
$cfg['Servers'][$i]['table_info'] = 'pma__table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma__column_info';
$cfg['Servers'][$i]['history'] = 'pma__history';
$cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
$cfg['Servers'][$i]['tracking'] = 'pma__tracking';
$cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
$cfg['Servers'][$i]['recent'] = 'pma__recent';
$cfg['Servers'][$i]['favorite'] = 'pma__favorite';
$cfg['Servers'][$i]['users'] = 'pma__users';
$cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
$cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
$cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';
$cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';


Attach event to dinamically added HTML elements with jQuery

If you have an event handler defined like this in JavaScript:


function edit_product(event) {

After adding elements (nodes) dinamically (after an AJAX call for example) that fit that selector to the HTML DOM with .append() or .html(), the event won’t work on them. That’s because the element was added AFTER calling the event method that links to the function we want to execute.

To ensure all elements that fit the selector will trigger the event you have to use .on() for example with $(document) as the ancestor:

$(document).on('click', "a[product-id]", edit_product);



Manual install and configuration of for Mac Ports in Mac OS X is an awesome profiler for PHP done by SensioLabs, the company behind Symfony2. It automatically instruments your code to gather data about consumed server resources like memory, CPU time, and I/O. It’s very useful to find bottlenecks in your code. is made of five main components:

  • The Agent is a server-side daemon that aggregates and forwards profiles to
  • The Probe is a PHP extension that gathers the raw performance profiles
  • The Client is a CLI tool used to trigger profiling
  • The Companion is a web browser extension used to trigger profiling
  • The Website is used to visualize the profiles


To use it in Mac OS X with Mac Ports you have to do a manual installation. Here is the different components installation process.


Download and install it’s files:

curl -O
tar xzvf blackfire-agent-darwin_amd64.tar.gz
sudo chown -R root:admin etc usr
sudo mv etc/blackfire /opt/local/etc/
sudo mv usr/share/man/man1/blackfire-agent.1.gz /opt/local/share/man/man1/
sudo mv usr/bin/blackfire* /opt/local/bin/
sudo mkdir -p /opt/local/var/log/blackfire
sudo ln -s /opt/local/etc/blackfire /usr/local/etc/blackfire

Create an agent configuration file in /opt/local/etc/blackfire/agent changing the log/socket files to the paths inside Mac Ports installation (/opt/local) and with your server id and token from


Now you can run it with this command:

sudo blackfire-agent

But it’s better to register a service using launchctl. Create a file called /Library/LaunchDaemons/com.sensiolabs.blackfire-agent.plist with this content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">

Make sure this file is owned by root:

sudo chown root:wheel /Library/LaunchDaemons/com.sensiolabs.blackfire-agent.plist

Load the service configuration file:

sudo launchctl load /Library/LaunchDaemons/com.sensiolabs.blackfire-agent.plist

And from now on you’ll be able to start and stop it as any other service:

sudo launchctl start com.sensiolabs.blackfire-agent
sudo launchctl stop com.sensiolabs.blackfire-agent

You can check if it’s really running using :

sudo ps x | grep blackfire


This is the extension used in the HTTP server. You need a different binary file depending on your PHP version. This script will download and configure it for you, you only need to change the server id and token:

PHP_VER=`php -v | head -n 1 | awk -F ' ' '{print $2}' | tr -d . | cut -c1-2`
EXT_DIR=`php -i | grep 'extension_dir' | awk -F ' => ' '{print $2}'`
sudo curl -o ${EXT_DIR}/${PHP_VER}.so
sudo chmod 755 ${EXT_DIR}/
PHP_INI=`php --ini | grep "Loaded Configuration File" | awk -F ' ' '{print $4}'`
echo "

blackfire.server_token=91bde3fa9350479ba84f90acab46b680142c0f6fe8154a649e82d0d2ddadfa93" | sudo tee -a $PHP_INI

Restart your HTTP server (Apache in my case) and also test with this command if the extension is correctly loaded by PHP:

php -m | grep blackfire


The client binary file is installed with the Agent in /opt/local/bin/blackfire but you can also download and install it separately:

curl -O
tar xzvf blackfire-cli-darwin_amd64.tar.gz
rm cli.sha1
sudo chown root:wheel cli
sudo mv cli /opt/local/bin/blackfire

Now configure the client file with the credentials from

blackfire config

This will create a file in your home folder called ~/.blackfire.ini. You’ll have to update it’s socket value so it’s the same as the one used in the Agent configuration file:



The companion is only available for Google Chrome at the moment from here: Install it and you’ll see a new icon in your browser that displays the different profiler slots.

Once everything is installed, configured and running just go to the URL in your server you want to profile and click “Profile!” in the Companion.



Doctrine ORM: Exception “Duplicate entry ‘2147483647’”

I was storing Facebook and Twitter profile IDs and I got this error:

  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2147
  483647' for key 'PRIMARY'

  SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '2147
  483647' for key 'PRIMARY'

When I went back to my data there was no ID with 2147483647 value. Then I realized that 2147483647 is the maximun value you can store in MySQL with a Doctrine integer type. So I just changed integer to bigint in my entities and the problem was solved.

class TwitterProfile
     * @ORM\Id
     * @ORM\Column(type="bigint")
    protected $id;


Clear internal DNS cache in Google Chrome

I was moving a client’s web from one hosting to another and after checking that the DNS registers have already been updated I could load the page on the new server in Chrome. It was like still trying to reach the old IP. Then I assumed Chrome has some kind of DNS cache, and sure it does. If you want to clear it open chrome://net-internals/#dns and press “Clear host cache”.