Behat installation through PEAR

Do yourself a favour and don’t even think about doing it, just go with the Composer method. Don’t waste time, seriously.

Here’s why:

  1. It simply doesn’t work out-of-the box. I have tried it on two clean ubuntu installs (which you can find on EC2 instances) as well as on Mac OS X Lion.
  2. Most likely, you won’t get the latest version (2.3.5 vs 2.4.0 at the time of writing), which is crucial in such edge technologies.

The problem

You will end up receiving an error message when trying to initialise it using behat --init:

[InvalidArgumentException]
[WARNING 1549] failed to load external entity "file:////usr/share/php/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd" (in n/a - line 0, column 0)
[WARNING 3084] Element '{http://www.w3.org/2001/XMLSchema}import': Failed to locate a schema at location 'file:////usr/share/php/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd'. Skipping the import . (in in_memory_buffer - line 8, column 0)
[ERROR 1845] Element '{http://symfony.com/schema/dic/services}container': No matching global declaration available for the validation root. (in /usr/share/php/behat/src/Behat/Behat/DependencyInjection/config/behat.xml - line 2, column 0)

The solution workaround

What you can do is to try to manually download services-1.0.xsd file into $PATH_TO_SYMFONY2/Component/DependencyInjection/Loader/ schema/dic/services. If you’re lucky enough, it will work – which was the case on one of my test setups – but you can end up seeing the following as well:

[InvalidArgumentException]
The service definition "behat.runner" does not exist.

Why bother?

Leave a Reply