Doctrine orm:convert-mappings errors on primary key

I will not say much on this since this is a dirty hack :)
Doctrine will not allow you to use the tool to generate entities out of the database that contains tables without primary key.
But, since they gave us the source code you can do something to bypass the error.

Go to DatabaseDriver.php
Search for reverseEngineerMappingFromDatabase method

uncomment the the following part as follows

            //if ( ! $table->hasPrimaryKey()) {
              //  throw new MappingException(
                //    "Table " . $table->getName() . " has no primary key. Doctrine does not ".
                  //  "support reverse engineering from tables that don't have a primary key."

            //$pkColumns = $table->getPrimaryKey()->getColumns();

and add on the next line

$pkColumns = array();

Then search for method getTablePrimaryKeys and comment everything inside it and return empty array.

That should give you what you want for NOW -:-|

, , , ,

Leave a comment

Check if the variable is defined in symfony twig

In twig, specially for the templates being used by many controllers, there might be variables set by one controller but not by others.

Well one way to address could be to have dummy data on each controller and either to check for that dummy value and do something or just to print it

But, symfony has a way to check if the variable has made it to the template or not

{% if some.variable is defined %} what a world {% endif %}

so the usage of defined can rescue us.

, , , ,

Leave a comment

XDebug connects but doesn’t stop on breakpoints

The first one would be just to double check if we have correct configuration for xdebug.
But the main and common culprit for this is using
inplace of

in php.ini

, , , , ,

Leave a comment

Serve more than one site using virtualhosts on mac OSX

There would be a need for this or that reason to serve more than one site from apache. And this is quite possible using configuration inside the apache

First thing first
go to the apache config, by default it should be


And search for

#Include /private/etc/apache2/extra/httpd-vhosts.conf

Which, as you can see, is commented. Hence uncomment that by deleting the # infront of it.

The above task will allow us to mess around the httpd-vhosts.conf file that is in the extras directory.

Lets assume we have a site names siteVH which is residing in the directory /www/sitevh
and lets assume we have another site called siteAnother residing in director /www/siteanother

Now the goal is to access those sites independently. So we will create two different virtual hosts for each one and be able to access them independently

    DocumentRoot "/www/siteVH"
    ErrorLog "/private/var/log/apache2/sitevh.log"
    CustomLog "/private/var/log/apache2/" common
        AllowOverride All
        Order allow,deny
        Allow from all
        Options Indexes FollowSymLinks

And the we will have the same duplicate values for the other one as well.

Then update the /etc/hosts to let know our local “DNS” :) to know what to do

This shall take care of the whole thing.
One more thing, restart apache

sudo apachectl restart

, , , , ,

Leave a comment

Change the name of computer in Mac

When setting up a new mac, you will have the default lengthy name that would appear on your terminal. Here is how to change the computer name in mac

On your terminal:

sudo scutil HostName short-name 

Where ‘short-name’ is what ever you want to be your computer name

That is it!

, , , , ,

Leave a comment

Mommy look.. Upgrading jQuery breaks live :(

If you have upgraded jQuery to 1.9 then you would have dreaded Uncaught TypeError: undefined is not a function would be barking at you on your javascript console.

The fix
According to the jQuery site, you would need to replace live with on

Say if you have:

$('.selector-class-name').live('click', function(){console.log('
Applications programming is a race between software engineers, who strive to produce idiot-proof programs, and the universe which strives to produce bigger idiots. So far the Universe is winning.
Rick Cook

Then you would have to change this to the new version using on as follows.
*The current on will be passed the event owner as a parameter so, we have to have a way to know the parent of the event owner, in this case the object with class selector-class-name.
If we don’t know the parent we can implement body tag

$('parent-of-object').on('click', '.selector-class-name', function(){
Applications programming is a race between software engineers, who strive to produce idiot-proof programs, and the universe which strives to produce bigger idiots. So far the Universe is winning.
Rick Cook

This shall take care of the problem.

, , , , , , , , ,

Leave a comment

View the raw sql created by Doctrine

For debugging you might want to see the final native query constructed by doctrine

$raw_sql = $query->getSQL();

the raw_sql variable would contain the sql constructed from entity objecs.

, , , , , , ,

Leave a comment


Get every new post delivered to your Inbox.