Installing Doctrine2 using PEAR

I was having a some sort of hell trying to install Doctrine via PEAR lately.
$sudo pear channel-discover
$sudo pear install -o

Was giving me errors like:
Package "" dependency "" has no releases
Package "" dependency "" has no releases
doctrine/DoctrineORM requires package "" (version >= 2.0.0)
doctrine/DoctrineORM requires package "" (version >= 2.0.0), installed version is 1.0.6
doctrine/DoctrineDBAL requires package "" (version >= 2.0.0)
No valid packages found
install failed

See, for some unknown reason the versions are not correct for the dependencies. Tried the solutions as stated in this StackOverflow topic for updating PEAR, but didn’t help!

Tried to remove/purge pear. But it didn’t help. Tried to install the Console, Yaml etc separately, also didn’t help.

Then when I tried to purge pear again I got the following error:

Removing php-pear …
Purging configuration files for php-pear ...
dpkg: warning: while removing php-pear, directory '/usr/share/doc/php5-common/PEAR' not empty so not removed
dpkg: warning: while removing php-pear, directory '/usr/share/php/.channels' not empty so not removed

There were some other folders which was reported to be not empty:

So, I removed them all!

Now, I again installed pear.

sudo apt-get install php-pear
Fingers crossed…

Added Doctrine channel: sudo pear channel-discover
And it didn’t say this time that channel is already in registry. Smiling…

Now to fire up doctrine installation, hope this time it works…
sudo pear install -o

et viola! it did!
Attempting to discover channel ""...
downloading channel.xml ...
Starting to download channel.xml (811 bytes)
....done: 811 bytes
Auto-discovered channel "", alias "symfony2", adding to registry
downloading DoctrineORM-2.3.0.tgz ...
Starting to download DoctrineORM-2.3.0.tgz (260,644 bytes)
...done: 260,644 bytes
downloading DoctrineCommon-2.3.0.tgz ...
Starting to download DoctrineCommon-2.3.0.tgz (59,473 bytes)
...done: 59,473 bytes
downloading DoctrineDBAL-2.3.0.tgz ...
Starting to download DoctrineDBAL-2.3.0.tgz (143,996 bytes)
...done: 143,996 bytes
downloading Console-2.1.3.tgz ...
Starting to download Console-2.1.3.tgz (51,354 bytes)
...done: 51,354 bytes
downloading Yaml-2.1.3.tgz ...
Starting to download Yaml-2.1.3.tgz (38,573 bytes)
...done: 38,573 bytes
install ok: channel://
install ok: channel://
install ok: channel://
install ok: channel://
install ok: channel://

Now lets test.
sudo pear list -c

Results in:
Installed packages, channel
Package Version State
DoctrineCommon 2.3.0 stable
DoctrineDBAL 2.3.0 stable
DoctrineORM 2.3.0 stable

Now, try doctrine at terminal:
lenin@office:/usr/share/php/.channels$ doctrine
Doctrine Command Line Interface version 2.3.0

 [options] command [arguments]
 --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:import Import SQL file(s) directly to Database.
 dbal:run-sql Executes arbitrary SQL directly from the command line.
 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.

So, thats it.