Here is my command on the terminal and I got a notice message
Note: PHPUnit is required in order to generate controller test stubs.
volition#volition-H61M-DS2:/var/www/register$ zf create action root Authentication
Note: PHPUnit is required in order to generate controller test stubs.
Creating an action named root inside controller at /var/www/register/application/controllers/AuthenticationController.php
Updating project profile '/var/www/register/.zfproject.xml'
Creating a view script for the root action method at /var/www/register/application/views/scripts/authentication/root.phtml
Updating project profile '/var/www/register/.zfproject.xml'
This is my include_path:
include_path .:/usr/share/php:/usr/share/pear
I don't know what I'm doing wrong here.
and also I want to know what is the use of phpUnit ??
It just is what it says. If you want to create test stubs, you need to have PHPUnit installed. Zend can automatically create tests for you when you generate code. It's not an error or a notice (as in E_NOTICE), it's simply a Note.
PHPUnit is a unit testing framework that helps you to test your code. If you don't know what that means, by all means go read the PHPUnit documentation.
First, install PEAR.
sudo apt-get install php-pear
Next, tell PEAR to update its own channel.
sudo pear channel-update pear.php.net
Then, tell PEAR to upgrade itself to the newest version.
sudo pear upgrade-all
You should now have the newest version of PEAR installed.
To install PHPUnit, let PEAR know where to find PHPUnit.
sudo pear channel-discover pear.phpunit.de
Then install PHPUnit. (the -a makes sure all dependency packages are also installed)
sudo pear install -a phpunit/PHPUnit
Update:
At Last Restart Apache
sudo /etc/init.d/apache2 restart
ohh You are using zend Framework
phpunit is installed in
C:\Zend\ZendServer\bin\PEAR
Add this line
include_path=".:/usr/share/php:/usr/share/pear:/usr/share/php/PHPunit:/usr/share/php/PEAR"
Related
I am trying to run behat on my vendor folder. I have installed composer globally, have installed the behat package, but every time I run bin/behat I keep getting this message from composer
You must set up the project dependencies, run the following commands:
curl -s http://getcomposer.org/installer | php
php composer.phar install
I am not sure how to fix this. I see the files are in the vendor folder, and when I type "composer" on the terminal, I see the manual.
If anyone can help me resolve this I would really appreciate it. Thanks!
There are several possible problems leading to this situation:
Make sure that composer is installed in your $PATH. That is, running composer at a command prompt should work, and you shouldn't need to run an explicit path like ~/Downloads/composer.phar
Execute the composer install instruction as the error message suggests. A common error is the message
Mcrypt PHP extension required
in which case you need to install the specified extension. For example, brew install php56-mcrypt on a Mac or sudo apt-get install php5-mcrypt on Ubuntu.
How to install phpunit?
I read documentation https://github.com/sebastianbergmann/phpunit, but have an error:
>pear upgrade PEAR
Nothing to upgrade
>pear config-set auto_discover 1
config-set succeeded
>pear install pear.phpunit.de/PHPUnit
No releases available for package "pear.phpunit.de/PHPUnit"
install failed
How can I fix this error?
Try the following instructions:
In the command prompt, switch to the directory that you installed PHP to by running cd C:\php\
Then install PEAR by running php go-pear.phar
Press Enter to accept the default when it asks you “Are you installing a system-wide PEAR or a local copy?”
Press Enter again to accept the file layout.
Press Enter to finish.
Run the following commands (they may take a while to update, be patient):
pear channel-update pear.php.net
pear upgrade-all
pear channel-discover pear.phpunit.de
pear channel-discover components.ez.no
pear channel-discover pear.symfony-project.com
pear update-channels
Clear your pear cache pear clear-cache
To install PHPUnit, run pear install --alldeps --force phpunit/PHPUnit
To test that PHPUnit was successfully installed, run phpunit -v
Old answer (2014):
It's said that phpunit will not be available via PEAR since December 2014.
So it's easy to install it using composer:
composer global require "phpunit/phpunit=4.1.*"
Update 2019: it should be installed as a local (for your project) development package:
composer require --dev phpunit/phpunit ^8
Update 2020: it should be installed as a local (for your project) development package:
composer require --dev phpunit/phpunit ^9.3
As said by #Wilt Installation via pear doesn't works any longer. Follow below steps instead
Step I: Create a directory named bin in C drive.
Step II: Now add the path C:\bin to your environment.
To do this click on Windows icon and right click on Computer and then
select Properties.
Then click on Advanced system settings -> Advanced
-> Environment Variables.
In the System variables section scroll down and select the line where the Variable column value is Path. Click on
Edit.
Now add (append at the end) ;C:\bin at the end.
Step III: Download phpunit phar file to C:\bin folder.
If you are PHP 7 then download the phar file from
https:// phar.phpunit.de/phpunit-6.2.phar.
Else if you are using PHP
5.6 then download the phar file from https:// phar.phpunit.de/phpunit-5.7.phar.
Once downloaded rename the
file to phpunit.phar and move it to C:\bin folder.
Step IV: Create a batch script phpunit.cmd
Open command prompt. Type cd C:\bin and hit enter.
Then type
echo #php "%~dp0phpunit.phar" %* > phpunit.cmd and hit enter.
To verify PHPUnit has been installed type phpunit --version in command prompt. You should get something like PHPUnit x.y.z by Sebastian Bergmann and contributors.
Reference: https://perials.com/installing-phpunit-windows/
I use Windows XP.
I wasted a lot of time trying to use pear (the proscribed method to get MakeGood working with Eclipse IDE), only to discover the repository for phpunit is no longer available. This information should be nearer the top of this page so people do not waste their time too.
I installed phpunit via the download at https://phpunit.de/ and following the accompanying instructions. By adding the path to the command file to PATH I can now run phpunit from the command line. I have not however got phpunit running in MakeGood/Eclipse. Much of the information on that is out-of-date as it requires pear.
Try this in Windows Subsystem for Linux (wsl):
sudo apt install phpunit
Can you walk me through the installation of a library for php, specifically what each terminal command does?
I have been learning web development for 6 months and it is time I need the console / terminal. I can't find any beginner walkthrough of using the terminal to add libraries and plugins to PHP. There are a lot of tutorials for specific steps or errors, but none start to finish.
If you want specifics to make your example concrete, here is what I am trying to install:
The library I am installing: http://code.google.com/p/phpquery/.
My directory for PHP on MAMP: /Applications/MAMP/bin/php/php5.3.6/bin
Thanks!
Don
edit:
I figured out my specific issue, but I don't think I really understand what I did, so I can't repeat it by myself in any other situation. This thread can help a lot of new terminal users including myself. The type of response I am looking for would go like this:
Step 1: Open your terminal. (This is an alternative way to navigate and execute commands on files on your computer).
Step 2: Find out where MAMP is installed however you like. Then go to your terminal, and type in cd followed by the path. cd stands for current directory and tells your terminal where it should execute its commands. The command you use will be very similar to this cd /Applications/MAMP. This will make your current directory MAMP.
Step 3: You are adding a library to PHP. So you need to go to the PHP folder in MAMP.... (please help us from this part!)
I just checked and it is available in pear channels.
# this is from their site
pear channel-discover phpquery-pear.appspot.com
pear install phpquery/phpQuery
Of course, for Mac using MAMP, you would use commands like this:
/Applications/MAMP/bin/php5/bin/pear install [package]
So for PHPQuery, try this:
/Applications/MAMP/bin/php5/bin/pear channel-discover phpquery-pear.appspot.com
/Applications/MAMP/bin/php5/bin/pear install phpquery/phpQuery
Same method should apply to pecl extensions as well.
EDIT
I personally just installed it on mine to test, here were my results:
$ /Applications/MAMP/bin/php5/bin/pear channel-discover phpquery-pear.appspot.com
Adding Channel "phpquery-pear.appspot.com" succeeded
Discovery of channel "phpquery-pear.appspot.com" succeeded
$ /Applications/MAMP/bin/php5/bin/pear install phpquery/phpQuery
downloading phpQuery-0.9.5.386-pear.tgz ...
Starting to download phpQuery-0.9.5.386-pear.tgz (100,990 bytes)
......................done: 100,990 bytes
install ok: channel://phpquery-pear.appspot.com/phpQuery-0.9.5.386
This should work with any PEAR or PECL extension. Check out this page for a list of PEAR packages.
EDIT 2
Make sure /Applications/MAMP/bin/php5/lib/php is in your include path! That is where phpQuery.php will be located once you've downloaded the PEAR packages properly with MAMP.
EDIT 3
Per cshu's comment, he mentioned that these packages are no longer maintained and that you should use this instead:
$ /Applications/MAMP/bin/php5/bin/pear channel-discover pear.querypath.org
$ /Applications/MAMP/bin/php5/bin/pear install querypath/QueryPath
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?)