Jason
Jason

Reputation: 11363

PHPUnit and Ubuntu - Issues with include path after Installation with PEAR

I need to install PHPUnit for a web dev project on my Ubuntu box, but am having serious issues. Using suggestions from various sources, I've installed via pear and tried the following:

when in /usr/share but throws errors everywhere else.

Any other suggestions would be appreciated.

Upvotes: 1

Views: 3120

Answers (3)

Marcos
Marcos

Reputation: 4930

Like Alister's answer, relying on Composer, but I prefer to deploy the updated PHPUnit globally across my projects with:

composer.phar global require "phpunit/phpunit=dev-master"

That way, when I am at the root dir of my Symfony project, I can just run

~/.composer/vendor/bin/phpunit -c app/ -v --filter testFireNotifications |tee phpunit.log

That last bit with --filter was to run something selectively (actually, more for fast web automation via crontab, than testing...)

Even on a current Ubuntu 14.04.2 server, the repo is stuck with an outdated PHPUnit 3.7.28 "stable", so I sidestep the OS-provided one with this custom install that won't conflict (I haven't put ~/.composer/vendor/bin in my PATH).

Upvotes: 0

Alister Bulman
Alister Bulman

Reputation: 35149

For recent projects, I'm using Composer to install PHPUnit and the other related tools. It's quite easy:

## ... rest of the composer.json file
# "php -f composer.phar update --dev" to install

"require-dev": {
  "phpunit/phpunit": "3.7.*"
},

I also then have a shell script to actually run the PHPUnit command-line tool from the ./vendor/bin/ directory where a link to the locally installed script is installed.

Upvotes: 0

DudeOnRock
DudeOnRock

Reputation: 3831

Search for a file on your computer that is called Autoload.php and is in a file structure like this: ../File/Iterator/Autoload.php

Now open the file that throws the error (/usr/share/php/PHPUnit/Autoload.php in your case) and include a set_include_path statement that points to the absolute path of that file.

You seem to have a very similar problem to what I experienced on Mac OSX. For more information look at this very similar question. If all of this doesn't help, try to install with Composer, which I have heard doesn't have this issue.

Upvotes: 2

Related Questions