I'm been at this for days with no success. Running Laravel 5.1.
As I understand according to the Laravel doc.
An ExampleTest.php file is provided in the tests directory. After installing a new Laravel application, simply run phpunit on the command line to run your tests.
Ok so after running phpunit I found it is not globally installed and is located in vendor/bin/phpunit. Proceeding to run vendor/bin/phpunit gives me a screen with all the command options for phpunit. Its does not actually run any tests.
I searched more and came across a post that mentioned it could be a symlink issue. I followed the instructions in the post with no success. From memory I installed Laravel from composer so the symlink should not be an issue anyway.
These instructions involved deleting various files. I did notice that composer was pulling files from its cache when updating. So I cleared its cache and followed the process again. Still no success.
What are the tests not running? I'm at my wits end. Especially since its is supposed to run easily out the box.
In the end I was not calling the bat file correctly. I was running
C:\localhost\myProject\vendor\bin> phpunit
Instead I needed to run
C:\localhost\myproject> call vendor\bin\phpunit
Hence it now is referencing the phpunit.xml file with the test location information.
You need to install phpunit globally:
composer global require phpunit/phpunit
Then you can run phpunit from your project root.
You could just run the phpunit that comes with the project, just go to your project root and run ./vendor/bin/phpunit, that way the tests will execute the way they should be and you could get feedback in case it fails.
For some reason I haven't figure out yet if you install phpunit globally in your computer you won't get feedback of your tests.
Related
I'm new to Lumen (and Laravel). I've created a project with Composer and now I'm trying to get PHPUnit to work.
I'm following a book, where it should be possible to run a default passing test by typing vendor/bin/phpunit in the terminal, but it gives the error:
'vendor' is not recognized as an internal or external command,
operable program or batch file
I've checked that the phpunit file is actually there and that phpunit is added as dependency in my composer.json file. I've also tried ./vendor/bin/phpunit and vendor/bin/phpunit/phpunit, but with the same result.
I've searched Google to find a solution, but everyone else seem to have issues when running phpunit (wihout vendor/bin) and the solution is to use the full path vendor/bin/phpunit, but since I'm already doing that, it does not fix my problem.
I'm using PHPStorm on a Windows machine and running the PHP server via PHPStorm. I've not modified the default Lumen project.
Any help is greatly appreciated!
UPDATE:
Trying php vendor/bin/phpunit gives the following error:
You need to set up the project dependencies using the following
commands:
wget http://getcomposer.org/composer.phar
php composer.phar install
I'm not sure what that means, since I've already installed Composer. I used Composer to create the project and I haven't changed the dependencies from the default.
I had the same problem, for Windows it's vendor\bin\phpunit ;)
It turned out that some symlinks and permissions were not installed properly in the default project. I tried deleting the entire vendor/ directory and run composer install.
Now I can run phpunit with the command vendor\bin\phpunit (because I'm running on Windows - thanks Nizarii)
try this:
php vendor/bin/phpunit
Try putting php in front of the phpunit path like so:
php vendor/bin/phpunit
I actually wanted to follow up on this question, but I guess It's better to start a new question.
I installed a fresh copy of my own laravel(5.0), and I tried running php artisan route:list, which works.
Now I have downloaded the compressed repository of a project I want to deploy on a shared hosting enviorment, but when I run php artisan route:list nothing happens.(No error message, nothing). Using this method for hosting the application
The actual problem is php artisan migrate, which also outputs nothing!
Is there a good method for troubleshooting this ?
Could you provide me we some points of failure that I can check ?
Worth mentioning:
I'm no Laravel developer and I have limited time reading up on it.
As LittleFinger suggested, it's possible that artisan is not actually yet installed. When deploying from a repo, Laravel's packages of which the entire framework core is composed, are not included. You should run composer install to install the packages. If you don't have composer installed that can be difficult on shared hosting, but it's usually possible to install it.
You will need to run composer install before you run composer update. Running composer update is not required, unless you want to update to the newest versions of your packages which are allowed by the rules in your composer.json file. This should be done with care in a production environment as new versions of packages could break your app.
Once you've installed the packages, you'll need to set your environment variables (database credentials etc.) by copying the .env.example file to .env and editing it. Once you've done this you'll be able to run php artisan key:generate to generate an encryption key.
After this, your app should work (assuming you've pointed a domain to the /public directory).
I am facing the same issue when I try to run
php artisan migrate or php artisan cache:clear
nothing happen just a blank screen no success no error see the screenshot
after debugging I found a message in error_log in root directory which says.
Fatal Error: Allowed Memory Size
after increasing the memory php artisan commands works fine
I am trying to run unit tests in a new laravel 5 application, using the phpunit framework. In the root path of my laravel application I ru the following command:
./vendor/bin/phpunit /tests/ExampleTest.php
And then I get the following message:
You need to set up the project dependencies using the following commands:
wget http://getcomposer.org/composer,phar
php composer.phar install
I already have composer installed in may system and I install Laravel 5 using composer. Isn't phpunit installed when I install a new laravel 5 application? If not, how can I install it in a existent laravel 5 application?
I known that I can also install phpunit globaly and resolve the problem. But maybe it will be a duplication since I have all the phpunit code already in may laravel application.
I had the same problem and it had a specific solution that may apply to other people. I store my files in Dropbox, and the vendor/bin/phpunit file should be an symlink like this
$ ls -lo vendor/bin/phpunit
lrwxr-xr-x vendor/bin/phpunit -> ../phpunit/phpunit/phpunit
However, Dropbox will occasionally replace symlinks with the original file, and this will cause the error above. The behaviour is inconsistent, and with relative symlinks seems to break when 2 machines are accessing Dropbox at the same time. Fixing the symlink worked for me or you could make a new symlink directly to the vendor/phpunit/phpunit/phpunit outside of Dropbox and run that.
Edit: Nowadays I exclude Vendor and node_modules from Dropbox - and simply run composer install when necessary. This works really well, and also deals with the hassle of syncing so many files on Dropbox. What you can do is go into the folder and delete all the files. Wait for Dropbox to sync. Then mark the folder as excluded. Finally, run composer install and you get the contents as you need. (Delete + composer install often solves other issues too).
Running composer install did nothing in my case. However, removing vendor folder and then calling composer install fixed it.
You need to have Composer installed and run composer install or composer update in your application to install the different packages listed in your composer.json.
When you install your Laravel application it doesn't install the packages right away.
You can verify the packages are installed by looking in the vendor directory of your application and check that phpunit is in there.
did you install phpunit globally? I recommend you do it.
just type in your laravel's root directory (e.g. /var/www)
cd /var/www
phpunit
if you what to test just one file, you can do something like this:
phpunit tests/ExampleTest.php
Unit Test:
D:\xampp\htdocs\Samplemed\vendor\bin>
phpunit ../../tests/Unit/Company/CompanyUnitTest
Feature Test:
D:\xampp\htdocs\Samplemed\vendor\bin>phpunit
../../tests/Feature/Company/CompanyFeatureTest
Please try this. its working fine.
I have installed PHPunit using composer. The application has unit test cases. from my project folder when i do a "phpunit" it gives me an error saying phpunit not found..but if i do a "./vendor/bin/phpunit" it will work. Any idea how to fix this ?
You need to add PHPUnit to your path. Include the ./vendor/bin/phpunit into your PATH environment (to be searched when looking for programs) in your OS.
I had the same problem and got tired of fiddling with PATHs on all my machines, so I wrote a small tool that makes composer behave a bit more like PEAR did:
https://github.com/flack/poser
You can use it to install Composer packages globally by running:
poser require phpunit/phpunit
Afterwards, calling phpunit on the shell will work as expected.
Today, I pulled down the laravel/laravel repository from Github. I then ran php composer.phar install (as I normally would on my system, with a command window in the project directory). However, when I ran php composer.phar update, I received this error:
Everything installed just fine, and Laravel works as it should.
Any ideas what could be causing this issue?
Edit 1
artisan exists in the root of the project, but it throws an exception when I attempt to run php artisan optimize:
Side Note 1
If I try the alternative method (quicker) of installing Laravel (php composer.phar create-project laravel/laravel), I get the following:
Edit 2
Upon installation, I also get the same error, where it claims it cannot find artisan. Therefore, the installation does not fully complete. I believe that it is stopping when it wants to compile classes (or something to that effect), and then write bootstrap/compiled.php. That file doesn't exist.
Here's the snap from the install:
Edit 3
It seems that Composer is looking for artisan in the drive root (C:\). Why is it doing this? Even if I specify -d on the update, it throws the error. (I picked this up from a hunch - simply copied artisan to the root of the drive and it found it - albeit, it obviously did not run...)
Solution Found:
Composer makes calls to php artisan <command> (as per the instruction in composer.json > scripts), but it does not see what directory it is running from (perhaps because it is an external command?).
So, I solved my initial problem by using an absolute path to artisan in composer.json.
Everything is working now. I just wish I knew how to get Composer to know that it is running from C:\LocalServer\lab\laravel, and not just C:\.
As i can see, your artisan file is missing. Can you post the exact steps on how you install it ?
Also, please follow http://laravel.com/docs/installation and http://niallobrien.me/2013/03/installing-and-updating-laravel-4/
I had this problem today too. My laravel folder inside the vendor was deleted after composer update. I ran composer install again and problem resolved.