Doctrine2 installation tip

March 12, 2012 | In: doctrine, doctrine2, install, installation, orm, setup, symfony2

In my previous post, i wrote about the Symfony2 installation tip, since Symfony uses Doctrine, so we need to install it as well.

According to this link, we will install it via pear:

$ pear channel-discover pear.doctrine-project.org
$ pear install --alldeps doctrine/DoctrineORM

Now let’s see if all went good.

$ doctrine
PHP Warning:  require(Doctrine/Symfony/Component/Console/Helper/HelperSet.php): failed to open stream: No such file or directory in /usr/share/php/Doctrine/Common/ClassLoader.php on line 163
PHP Stack trace:
PHP   1. {main}() /usr/bin/doctrine:0
PHP   2. include() /usr/bin/doctrine:4
PHP   3. Doctrine\Common\ClassLoader->loadClass() /usr/share/php/Doctrine/Common/ClassLoader.php:0
PHP Fatal error:  require(): Failed opening required 'Doctrine/Symfony/Component/Console/Helper/HelperSet.php' (include_path='.:/usr/share/php:/usr/share/pear') in /usr/share/php/Doctrine/Common/ClassLoader.php on line 163
PHP Stack trace:
PHP   1. {main}() /usr/bin/doctrine:0
PHP   2. include() /usr/bin/doctrine:4
PHP   3. Doctrine\Common\ClassLoader->loadClass() /usr/share/php/Doctrine/Common/ClassLoader.php:0

Houston we got a problem.

This error occured on my current machine setup, Ubuntu 11.04 with all the default pear/php stuff configurations installed via : ‘apt-get’.

But wait, the problem is not that hard to fix, it just cannot find the symfony core files because it’s looking under Doctrine folder.

Current Symfony installation dir is at:

$ ls -l /usr/share/php/Symfony
total 12
drwxr-xr-x  3 root root 4096 2012-03-10 13:54 ./
drwxr-xr-x 34 root root 4096 2012-03-12 22:51 ../
drwxr-xr-x 13 root root 4096 2012-03-10 13:57 Component/

Current Doctine installation dir is at:

$ ls -l /usr/share/php/Doctrine/
total 20
drwxr-xr-x  5 root root 4096 2012-03-12 23:01 ./
drwxr-xr-x 34 root root 4096 2012-03-12 22:51 ../
drwxr-xr-x  7 root root 4096 2012-03-12 22:51 Common/
drwxr-xr-x 13 root root 4096 2012-03-12 22:51 DBAL/
drwxr-xr-x 10 root root 4096 2012-03-12 22:51 ORM/

Doctrine2 is looking for Symfony under Doctrine. What we need to do to fix is instead of copying/moving Symfony folder , we can just create a symlink (symbolic link) into it.

$ sudo ln -s /usr/share/php/Symfony /usr/share/php/Doctrine/Symfony

Now, let’s try again if this works:

$ doctrine
Doctrine Command Line Interface version 2.2.1

Usage:
  [options] command [arguments]

Options:
  --help           -h Display this help message.
  --quiet          -q Do not output any message.
  --verbose        -v Increase verbosity of messages.
  --version        -V Display this application version.
  --ansi              Force ANSI output.
  --no-ansi           Disable ANSI output.
  --no-interaction -n Do not ask any interactive question.

Available commands:
  help                             Displays help for a command
  list                             Lists commands
dbal
  dbal:import                      Import SQL file(s) directly to Database.
  dbal:run-sql                     Executes arbitrary SQL directly from the command line.
orm
  orm:clear-cache:metadata         Clear all metadata cache of the various cache drivers.
  orm:clear-cache:query            Clear all query cache of the various cache drivers.
  orm:clear-cache:result           Clear all result cache of the various cache drivers.
  orm:convert-d1-schema            Converts Doctrine 1.X schema into a Doctrine 2.X schema.
  orm:convert-mapping              Convert mapping information between supported formats.
  orm:ensure-production-settings   Verify that Doctrine is properly configured for a production environment.
  orm:generate-entities            Generate entity classes and method stubs from your mapping information.
  orm:generate-proxies             Generates proxy classes for entity classes.
  orm:generate-repositories        Generate repository classes from your mapping information.
  orm:info                         Show basic information about all mapped entities
  orm:run-dql                      Executes arbitrary DQL directly from the command line.
  orm:schema-tool:create           Processes the schema and either create it directly on EntityManager Storage Connection or generate the SQL output.
  orm:schema-tool:drop             Drop the complete database schema of EntityManager Storage Connection or generate the corresponding SQL output.
  orm:schema-tool:update           Executes (or dumps) the SQL needed to update the database schema to match the current mapping metadata.
  orm:validate-schema              Validate the mapping files.

Sweet, HTH!



3 Responses to Doctrine2 installation tip

Avatar

Derek

June 20th, 2012 at 4:50 pm

Oh yeah so its is!
Cheers for that 🙂

Avatar

mainvoid

August 22nd, 2012 at 5:49 pm

Thx 🙂

Avatar

zeratool

August 22nd, 2012 at 7:49 pm

No problem.

Comment Form