I'm searching for the solution for a day but i have no luck.
I already install Zend Framework on Mac OS 10.9, i also install PHPUnit via pear. But when i tried to create a project it show up a message
Testing Note: PHPUnit was not found in your include_path, therefore no testing actions will be created.
This is my pear localtion: /usr/bin/pear
This is my phpunit location: /usr/bin/phpunit
Thank you so much!
How did you install PHPUnit?
It is "just" not included in your include_path - that is it.
You need to add it's base path to the Zend Autoloader - here's how.
composer is also an option as #Eddie Jaoude mentioned.
The main difference between using composer and pear is that pear installs its packages globally and you need to include them in your path (to load them). composer on the other hand installs them locally in the project in your vendors directory and automatically handles auto loading for you.
Related
I have a fresh symfony project and I need to install phpunit, so I run composer require --dev symfony/phpunit-bridge to install it. It creating symlink to phpunit executable in bin/ folder. But when I'm running tests using bin/phpuinit tests/ command I'm getting message "No composer.json found in the current directory, showing available packages from packagist.org
" and it starting phpunit installation into bin directory and at the end I have bin/.phpunit folder and all the phpunit related files there. Why it installing php unit there and not into vendor, why it's not see composer??? what I'm doing wrong ? Thanks in advance!
What you are using is the symfony/phpunit-bridge
It basically is way more flexible than just phpunit in the vendor folder, allowing to adapt to multiple versions of PHPUnit based on your environment.
Please read the documentation linked above for more details. You're not doing anything wrong!
Another way would be a plain composer require phpunit/phpunit, which would work the "basic"/"standard" way.
I've installed the latest version of CakePHP, then installed PHPUnit using PEAR and tried to get access using such link as
http://localhost/[project_name]/test.php
But as a result I've got a message that PHPUnit is not installed. I can't understand what the problem is. Are there any other ways to solve this problem ?
And is it possible not to install PHPUnit, but just copy all its files to, for example, Vendor directory of CakePHP and to use it locally just for one separate project ?
I disagree with Mark. :)
The most easy way to install phpunit systemwide is using composer as described on their installation page:
For a system-wide installation via Composer, you can run:
composer global require 'phpunit/phpunit=3.7.*'
The easiest way in Win is https://github.com/dereuromark/cakephp-phpunit
That is standalone and will all work out of the box with
cake Phpunit.Phpunit install
It has no dependencies outside of CakePHP itself. No composer, no pear no other 3rdparty issues.
If you do have one of those dependencies available, use that one, though.
Note:
As of now the pear channel has been shut down and as such there is only the composer solution to it now. (See other answer)
Is there a default location to store the PHPUNIT extension?
I'm using symfony2 and each time I want to use phpunit I have to run this in terminal export PATH=$PATH:/usr/local/zend/apache2/htdocs/symfony/app
Is this normal? or is there a way to make it always work, even if I update and rename my symfony folder to something else.
Is there a way to make it always work?
I'm using zend server ce and snow leopard 10.6+
When I installed PHPUnit using the PEAR installer, it put phpunit in /usr/bin which was already on my path. This way I could type phpunit anywhere to run in the current directory.
What platform?
Ubuntu for me
How did you install PHPUnit?
pear install phpunit/PHPUnit
How does Symphony2 relate here?
Are you trying to run its tests or your own tests that use Symphony?
Resolved!
I uninstalled phpunit from pear and then reinstalled it again. I believe I was using the wrong/old/not enough sources before installing. Works like a charm!
So I'm trying to set up PEAR & PHPUnit. I was following http://www.newmediacampaigns.com/page/install-pear-phpunit-xdebug-on-macosx-snow-leopard but after I installed pear I had a different directory structure in /usr/local. Regardless, I was able run the phpunit install. But now I'm lost and asking for help before I make a bigger mess :)
pear config-show says:
PEAR directory php_dir /usr/local/share/pear
And my php.ini file (and confirmed in phpinfo() says:
include_path=".:/usr/local/share/pear"
So that's good, right? But now what? I get
Failed opening required 'PHPUnit/Framework.php' (include_path='.:/usr/local/share/pear')
If I try to include it in the php. And I have no idea where the binary might be to run it from the command line.
Inside /usr/local/share/pear/PHPUnit there are two directories "Extensions" and "Framework"
It sometimes happen that the install fails on PHPUnit specifically, but succeeds on the dependencies, so it only looks like the install was succesfull.
Try this when installing
pear install --force --alldeps phpunit/PHPUnit
The --force option will force the install of PHPUnit, even if all the dependencies can't be met. In my case there was a missing dependency for the dom PHP extension which blocked the installation even though the PHP_Invoker package could be used instead.
The --alldeps option makes sure that all of the dependencies got installed.
Check for a bin directory in the pear install, something along the lines of /usr/local/share/pear/bin/ - your install is different than mine..
You could also try searching for the binary -
find /usr/local/share/pear -name 'phpunit'
I'm working on a project that'll use PEAR packages. Because you never know what version of the PEAR package will be installed on your hosting provider (and especially because I require a patch to have been applied to one of the packages), I'd like to put the PEAR source for my project right into SVN, so other developers can immediately have the dependencies.
But everything related to PEAR seems to have absolute directories! Running "pear config-create . pear.conf" to set up a new PEAR directory even fails with the error message:
Root directory must be an absolute path
I checked out the pear config files on some other servers and they, too, seem to have absolute paths.
Whenever a developer checks this out to his own machine, or we export it all to a server, we don't know what the absolute path will be.
Is there any way to set this up?
I couldn't get my Hosting provider to install the PEAR libraries I wanted. Here's how I made PEAR part of my source tree.
1. Create a remote.conf file
Creating your remote.conf is a little different than in the manual. Lets say I want to install PEAR in vendor/PEAR of a project. You would do it like this:
#from the root of the project
$ cd vendor ; mkdir PEAR ; cd PEAR
$ pear config-create <absolute path to project>/vendor/PEAR/ remote.conf
2.Update the channels
$ pear -c remote.conf channel-update pear.php.net
3. install PEAR
$ pear -c remote.conf install --alldeps pear
4. install any other libraries
$ pear -c remote.conf install --alldeps <libname>
Voila... PEAR is part of the source tree.
The Catches:
Even though the paths in remote.conf are absolute the libraries themselves will still work. It's just updating that won't work from anywhere. You will need to update it from the same path that it was created from -- in the above case, from vendor/PEAR.
Some libraries don't like being outside the path, so you may have to add vendor/PEAR to the path (I've got code, just ask if you need.)
If you have PHP 5.3.1 use Pyrus, the PEAR2 installer. The pyrus managed installations can be moved where ever you like.
Download pyrus -
$> wget http://pear2.php.net/pyrus.phar
Create a directory to store your pyrus-installed packages:
$> mkdir mylibs
Install packages -
$> php pyrus.phar mylibs install pear/Net_URL
Your installed package is now at mylibs/php/Net/URL.php
Note that we passed the mylibs directory to indicate what directory to install to, as well as the channel name 'pear' (the default in pyrus is pear2.php.net). For convenience, the pyrus.phar file can be executed from cli if you chmod +x it.
You can move the mylibs directory wherever you'd like. Even commit it to your repository.
Lots of docs on the PEAR website.
I'm note entirely sure if this answers your question, but you can specify the location for the PEAR repository on the commandline, so you can create a local repository, using:
pear install --force --installroot=/path/to/my/pear/ PEAR
Then you can install additional packages using:
pear install --installroot=/path/to/my/pear/ SomePackage
To use the local repo from within your app, you have to make sure that the include_path points to the local repo, rather than the default (globally installed) repository. So you'd want it to look like this:
include_path = ".:/path/to/my/pear/usr/share/php"
Re :
Actually, he wants to avoid the absolute paths so that the solution can be checked out from many machines without depending on the path each one has the repository installed.
-- Carlos Lima
Seems you're right. In that case, I would advice that you don't check the PEAR repository into your SVN repository, but rather use a deploy script to install/update the repository at the server. Just make sure to install a particular version. (You do have an automated deploy, right?)