I am new to phpunit and I am trying to get it working with PHP storm. I have added composer and I have added the phpunit dependency and the files are all there. But when I try call phpunit in the command line I get this error.
I can't figure this out because I have tried calling phpunit and I have tried going through the folders to the files phpunit and phpunit.bat. Here is a picture of the folders and files.
It displays an error since your php is not being recognized. In order to fix the problem, you need to add your php directory to your PATH Environment Variable.
Screenshot of My System Variable
To verify that your php is now being recognized by the system, run the command php --version in your command prompt. It should display the version of your PHP
Related
Does anyone know the correct command line to generate a code coverage file on a PHP project? I've already installed the XDebug tool.
In the official documentation from PHPUnit, I found the following command line, but it is not working:
phpunit --coverage-text=<file>
where is the file where output is going to be stored.
I don't have any tests yet, but is there a way to generate a report file, even though there are no tests in the project?
You'll need to include the path to your tests, as well as the white list command with the path to the source code to be tested. E.g.
phpunit --coverage-text="coverage.txt" ./path/to/tests --whitelist="./path/to/code"
Where coverage.txt is the file that the output will be stored in. You can generate a report without any tests.
I have problem with my PHP and composer. I have set environment variables:
But whenever I call php or composer I get an error:
It's weird, because when I start cmd as an admin it works. But I want it to work always, because its much easier to write cmd to navigation path which opens the command line in exact path I use and don't need to write cd commands every time I need something.
Have you tried installing composer with the Windows GUI? If I remember correctly, it sets up your path variables itself.
https://getcomposer.org/doc/00-intro.md#installation-windows
You could try adding the same path to your user path variables too, in the first box. I guess you're restarting your CMD window?
I'm trying to create something similar to the laravel installer, it's a PHP Script that utilises Symfony's Console Component. It all works fine except I can't seem to get the damn thing to execute globally on my command line.
I've currently got the script(boiler) stored as /dir/dir/vendor/author/packagename/boiler.
Via Composer I also have a symlink that points to the script from /dir/dir/vendor/bin/. Automatically done via bin in composer.json.
I've updated my $PATH, which now shows /folder/folder/vendor/bin/ to point to the symlink;
My script starts:
#!/usr/bin/env php
Permissions are:
-rwxr-xr-x
I'm running Zshell on Mac OSX.
It will run if I go into the directory and type php boiler but boilerreturns command not found and if I'm in a different directory boiler also returns command not found. php boiler returns "Could not open input file: boiler"
The laravel installer runs exactly as I want mine to, using just laravel whilst anywhere on the command line.
At a complete loss. Google isn't turning up any similar issues, and neither is Stack (My searching ability may be lacking though, it's 4am.)
For those with similar issues:
Use which commandName to see if it's correctly added to your $PATH
Check the symlink is correct if it's via one
Check permissions on symlink and executable script
Post to stackoverflow so that it'll just.. fix itself.
So... which boiler returned the correct path so I tried boiler again from my home dir and it worked.
I genuinely haven't changed a single thing and been stuck for an hour. I don't understand...
Thanks all for help.
I am using windows system. I have just installed the symfony to my localhost as it is install with no error inside.
bellow url run fine with browser.
http://localhost/symfony/web/app_dev.php
now i have tried to create bundle from command prompt with following syntax.
php app/console generate:bundle --namespace=Acme/HelloBundle --format=yml
it shows an error like. "could not open input file."
however the environment variable is already set for command prompt.
so can any one please help me create bundle or give another way to create bundle in symfony.
Thanks.
What environment variable is set? Best thing is to run this command while you are in main project folder (in your case symfony folder).
Could not open input file.
implifies that app/console, does not exist. Make sure to run
cd path/to/your/symfony/folder
before trying to generate the bundle. :)
Run your command from your symfony root folder. Also try to do:
php app/console generate:bundle
it will ask you to specify a folder and format. Also that it needs to generate the structure.
Also check that your php-cli.ini has all the necessary configurations to execute the code.
I've just upgraded PHP to the latest version. When I get back to Git, to my command shell, if I execute any PHP function, then I get this error :
sh.exe": php: command not found
I know I have to tell git bash where my new PHP path is, but I don't know how to do so and I can't find anything on Google about that.
EDIT :
I made a confusion you're right : I meant Git BASH by git. Thanks :)
SO here is the function I tried to call when I was dealing with symfony in the root foler of my app :
php app/console dump-sql
then Git BASH sent me the error above.
If you are windows, then following up on halfer's comment, it is required that you add the new
/bin/ directory of the php folder to your PATH.
To do this:
1. Open start menu
2. Right click my computer->properties
3. Click advanced tab -> Environment variables
4. Scroll down in the second listbox for a entry called PATH
5. add this to the end ;C:/%PHP_LOCATION%/bin
where %PHP_LOCATION% is the place that you installed PHP to.
I think you have git and bash confused.
Git is a program that would be running under bash, and isn't directly related to git unless you've gone out of your way to entangle them.
Most likely, the incantation you need is
export PATH=/path/where/php/is:$PATH
And then everything will be working. Note that needs to be the path to the directory, not the binary.
the $PATH at the end is to make sure that you don't clobber your old path.
I had the same error. I found that I needed the environment variable path in this format:
/c/wamp/bin/php/php5.3.13 (instead of C:\wamp\bin\php\php5.3.13)
Using Windows 7 & Git 1.7.10.