New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught exception 'Illuminate\Contracts\Container\BindingResolutionException' #11192

Closed
PhillippOhlandt opened this Issue Dec 4, 2015 · 28 comments

Comments

Projects
None yet
@PhillippOhlandt

PhillippOhlandt commented Dec 4, 2015

Hey,

when I install a fresh version of Laravel 5.1 through the Installer and run phpunit I get:

Fatal error: Call to undefined method PHPUnit_Framework_TestResult::warningCount() in /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php on line 185
PHP Fatal error:  Uncaught exception 'Illuminate\Contracts\Container\BindingResolutionException' with message 'Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable.' in /home/vagrant/Private/test/vendor/laravel/framework/src/Illuminate/Container/Container.php:745
Stack trace:
#0 /home/vagrant/Private/test/vendor/laravel/framework/src/Illuminate/Container/Container.php(627): Illuminate\Container\Container->build('Illuminate\\Cont...', Array)
#1 /home/vagrant/Private/test/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(674): Illuminate\Container\Container->make('Illuminate\\Cont...', Array)
#2 /home/vagrant/Private/test/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(154): Illuminate\Foundation\Application->make('Illuminate\\Cont...')
#3 /home/vagrant/Private/test/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(79): Illuminate\Foundation\Bootstrap\HandleExceptions->getExceptionHandler()
#4 /home/vagrant/Private/test/vendor/ in /home/vagrant/Private/test/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 745

Same error on php7.0 and php5.6.

@GrahamCampbell

This comment has been minimized.

Show comment
Hide comment
@GrahamCampbell

GrahamCampbell Dec 4, 2015

Member

What version of phpunit?

Member

GrahamCampbell commented Dec 4, 2015

What version of phpunit?

@GrahamCampbell

This comment has been minimized.

Show comment
Hide comment
@GrahamCampbell

GrahamCampbell Dec 4, 2015

Member

Only 4.x, and 5.0 are known to work with laravel.

Member

GrahamCampbell commented Dec 4, 2015

Only 4.x, and 5.0 are known to work with laravel.

@GrahamCampbell

This comment has been minimized.

Show comment
Hide comment
@GrahamCampbell

GrahamCampbell Dec 4, 2015

Member

5.1+ don't work correctly atm.

Member

GrahamCampbell commented Dec 4, 2015

5.1+ don't work correctly atm.

@PhillippOhlandt

This comment has been minimized.

Show comment
Hide comment
@PhillippOhlandt

PhillippOhlandt Dec 4, 2015

php 5.6.13 and laravel 5.1.23

PhillippOhlandt commented Dec 4, 2015

php 5.6.13 and laravel 5.1.23

@darthmaim

This comment has been minimized.

Show comment
Hide comment
@darthmaim

darthmaim Dec 4, 2015

What version of phpunit?

darthmaim commented Dec 4, 2015

What version of phpunit?

@PhillippOhlandt

This comment has been minimized.

Show comment
Hide comment
@PhillippOhlandt

PhillippOhlandt Dec 4, 2015

PHPUnit 4.8.19

PhillippOhlandt commented Dec 4, 2015

PHPUnit 4.8.19

@GrahamCampbell

This comment has been minimized.

Show comment
Hide comment
@GrahamCampbell

GrahamCampbell Dec 4, 2015

Member

Hmmm. Thanks for reporting. Ping @taylorotwell.

Member

GrahamCampbell commented Dec 4, 2015

Hmmm. Thanks for reporting. Ping @taylorotwell.

@crynobone

This comment has been minimized.

Show comment
Hide comment
@crynobone

crynobone Dec 4, 2015

Contributor

when I install a fresh version of Laravel 5.1 through the Installer

The installer doesn't generate .env, and most likely due to APP_KEY not being set due to the missing file, PHPUnit throws this exception.

Could you try running:

composer run-script post-root-package-install
php artisan key:generate

and run phpunit again.

Contributor

crynobone commented Dec 4, 2015

when I install a fresh version of Laravel 5.1 through the Installer

The installer doesn't generate .env, and most likely due to APP_KEY not being set due to the missing file, PHPUnit throws this exception.

Could you try running:

composer run-script post-root-package-install
php artisan key:generate

and run phpunit again.

@PhillippOhlandt

This comment has been minimized.

Show comment
Hide comment
@PhillippOhlandt

PhillippOhlandt Dec 4, 2015

@crynobone the .env file was generated with the installer, see:

Phillipps-MacBook-Pro ~/Private/Code/test$ cat .env
APP_ENV=local
APP_DEBUG=true
APP_KEY=V4Y9bY6YFVHzPQEALF2qzfz3IqbUAuDW

DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PhillippOhlandt commented Dec 4, 2015

@crynobone the .env file was generated with the installer, see:

Phillipps-MacBook-Pro ~/Private/Code/test$ cat .env
APP_ENV=local
APP_DEBUG=true
APP_KEY=V4Y9bY6YFVHzPQEALF2qzfz3IqbUAuDW

DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
@crynobone

This comment has been minimized.

Show comment
Hide comment
@crynobone

crynobone Dec 4, 2015

Contributor

screen shot 2015-12-04 at 7 34 34 pm

Works fine with composer create-project.

Contributor

crynobone commented Dec 4, 2015

screen shot 2015-12-04 at 7 34 34 pm

Works fine with composer create-project.

@PhillippOhlandt

This comment has been minimized.

Show comment
Hide comment
@PhillippOhlandt

PhillippOhlandt Dec 4, 2015

Weird, tried it with 'composer create-project' and got the same error.

PhillippOhlandt commented Dec 4, 2015

Weird, tried it with 'composer create-project' and got the same error.

@PhillippOhlandt

This comment has been minimized.

Show comment
Hide comment
@PhillippOhlandt

PhillippOhlandt Dec 4, 2015

When i try it inside the vagrant vm, then it works, lol. But the version installed by the laravel Installer still fails.

PhillippOhlandt commented Dec 4, 2015

When i try it inside the vagrant vm, then it works, lol. But the version installed by the laravel Installer still fails.

@crynobone

This comment has been minimized.

Show comment
Hide comment
@crynobone

crynobone Dec 4, 2015

Contributor

could it be something installed in your composer global that could trigger the problem. That would explain why it work fine in vagrant vm.

Contributor

crynobone commented Dec 4, 2015

could it be something installed in your composer global that could trigger the problem. That would explain why it work fine in vagrant vm.

@PhillippOhlandt

This comment has been minimized.

Show comment
Hide comment
@PhillippOhlandt

PhillippOhlandt Dec 4, 2015

I dont think so because the installer version fails and the composer create-project doesn't fail in the vm. But what's the difference?

PhillippOhlandt commented Dec 4, 2015

I dont think so because the installer version fails and the composer create-project doesn't fail in the vm. But what's the difference?

@PhillippOhlandt

This comment has been minimized.

Show comment
Hide comment
@PhillippOhlandt

PhillippOhlandt Dec 4, 2015

Another weird thing is: I have to use 'sudo' on the laravel installer one when i run phpunit.

PhillippOhlandt commented Dec 4, 2015

Another weird thing is: I have to use 'sudo' on the laravel installer one when i run phpunit.

@PhillippOhlandt

This comment has been minimized.

Show comment
Hide comment
@PhillippOhlandt

PhillippOhlandt Dec 4, 2015

I solved it!

First I had to remove the vendor folder and install everything again, then I had to remove phpunit globally and set an alias for phpunit so it uses the local phpunit from the vendor folder. Now everything work.

PhillippOhlandt commented Dec 4, 2015

I solved it!

First I had to remove the vendor folder and install everything again, then I had to remove phpunit globally and set an alias for phpunit so it uses the local phpunit from the vendor folder. Now everything work.

@husonghua

This comment has been minimized.

Show comment
Hide comment
@husonghua

husonghua Dec 9, 2015

The removal of vendor folder did not work for me. However, I was able to resolve the issue by upgrading phpunit from 4.8.19 to 5.0.

husonghua commented Dec 9, 2015

The removal of vendor folder did not work for me. However, I was able to resolve the issue by upgrading phpunit from 4.8.19 to 5.0.

@PhillippOhlandt

This comment has been minimized.

Show comment
Hide comment
@PhillippOhlandt

PhillippOhlandt Dec 9, 2015

@husonghua I had to remove it because of wrong permissions on the binary. Reinstalling through composer set the right permissions then.

PhillippOhlandt commented Dec 9, 2015

@husonghua I had to remove it because of wrong permissions on the binary. Reinstalling through composer set the right permissions then.

@AwesomeBobX64

This comment has been minimized.

Show comment
Hide comment
@AwesomeBobX64

AwesomeBobX64 Dec 11, 2015

@PhillippOhlandt, what version of PHPUnit are you using then? I'm having this problem when I run unit tests.

Laravel 5.1, PHPUnit 5.1.

AwesomeBobX64 commented Dec 11, 2015

@PhillippOhlandt, what version of PHPUnit are you using then? I'm having this problem when I run unit tests.

Laravel 5.1, PHPUnit 5.1.

@AwesomeBobX64

This comment has been minimized.

Show comment
Hide comment
@AwesomeBobX64

AwesomeBobX64 Dec 11, 2015

Looks like a project my project lives inside had an autoloader which used their version of PHPUnit's files which were PHPUnit 5.0. Upgraded them to PHPUnit 5.1 and my issues are gone.

AwesomeBobX64 commented Dec 11, 2015

Looks like a project my project lives inside had an autoloader which used their version of PHPUnit's files which were PHPUnit 5.0. Upgraded them to PHPUnit 5.1 and my issues are gone.

@driverInside

This comment has been minimized.

Show comment
Hide comment
@driverInside

driverInside Dec 21, 2015

I solved this issue in my computer changing the phpunit version in my composer.json file.
(I have composer installed in my home directory, so I edited ~/.composer/composer.json file)

"require": {
...
"phpunit/phpunit": "~4.0"
}

Cause is the default version when you create a project (via composer or laravel new).
I guess I had this trouble because phpunit called ~/.composer/vendor/bin instead the local project. Actually the error was throw in ~/.composer/vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php (See logs)

Then:

composer update 

At the end, I guess is more simple use vendor/bin directory to use phpunit

driverInside commented Dec 21, 2015

I solved this issue in my computer changing the phpunit version in my composer.json file.
(I have composer installed in my home directory, so I edited ~/.composer/composer.json file)

"require": {
...
"phpunit/phpunit": "~4.0"
}

Cause is the default version when you create a project (via composer or laravel new).
I guess I had this trouble because phpunit called ~/.composer/vendor/bin instead the local project. Actually the error was throw in ~/.composer/vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php (See logs)

Then:

composer update 

At the end, I guess is more simple use vendor/bin directory to use phpunit

@matiux

This comment has been minimized.

Show comment
Hide comment
@matiux

matiux Dec 28, 2015

I use Debian with phpunit 5.1.3 installed as a command in my system and I have the same problem:
Call to undefined method PHPUnit_Framework_TestResult::warningCount() in /usr/share/php/PHPUnit/TextUI/ResultPrinter.php on line 185

How can I solve?

matiux commented Dec 28, 2015

I use Debian with phpunit 5.1.3 installed as a command in my system and I have the same problem:
Call to undefined method PHPUnit_Framework_TestResult::warningCount() in /usr/share/php/PHPUnit/TextUI/ResultPrinter.php on line 185

How can I solve?

@christophelimpalair

This comment has been minimized.

Show comment
Hide comment
@christophelimpalair

christophelimpalair Jan 2, 2016

I had the same problem. Updating to 5.1.3 fixed it for me.

christophelimpalair commented Jan 2, 2016

I had the same problem. Updating to 5.1.3 fixed it for me.

@JSheils

This comment has been minimized.

Show comment
Hide comment
@JSheils

JSheils May 1, 2016

I had the same problem and solved it by upgrading to phpunit 5.3.2. I suspect it has less to do with the version than with re-installing phpunit after maybe composer missed something the first time.

JSheils commented May 1, 2016

I had the same problem and solved it by upgrading to phpunit 5.3.2. I suspect it has less to do with the version than with re-installing phpunit after maybe composer missed something the first time.

@canaan5

This comment has been minimized.

Show comment
Hide comment
@canaan5

canaan5 May 9, 2016

is there no real fix for this error yet?

canaan5 commented May 9, 2016

is there no real fix for this error yet?

@priyanganamal

This comment has been minimized.

Show comment
Hide comment
@priyanganamal

priyanganamal May 18, 2016

ResultPrinter.php issue has been fixed in newer versions. My issue is fixed after updating version of phpunit to 5.0 in composer.json and composer update.

"phpunit/phpunit": "~5.0",

priyanganamal commented May 18, 2016

ResultPrinter.php issue has been fixed in newer versions. My issue is fixed after updating version of phpunit to 5.0 in composer.json and composer update.

"phpunit/phpunit": "~5.0",

@tpraxl

This comment has been minimized.

Show comment
Hide comment
@tpraxl

tpraxl Jul 14, 2016

Contributor

I can confirm that updating in composer.json works.
My issue was:

  • laravel 5.2.* application with homestead
  • composer.json defined phpunit version to be ~4.0
  • local (host) system: linux, phpunit version 4.8.23
  • vagrant (guest) system: phpunit version 5.1.3 (installed with sudo apt-get install -y phpunit in {project-root}/after.sh)

phpunit would work when called on my local system, but not inside vagrant vm. Inside the vm it would fail with the message PHP Fatal error: Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable.

After changing composer.json to the below and running composer update, everything works fine again. Remember that I didn't touch my installed phpunit versions.

Update composer.json:

"require-dev": {
   [...]
   "phpunit/phpunit": "~5.0", 
   [...]
}

then run

composer update

Thanks for your hints. Helped me a lot.

Contributor

tpraxl commented Jul 14, 2016

I can confirm that updating in composer.json works.
My issue was:

  • laravel 5.2.* application with homestead
  • composer.json defined phpunit version to be ~4.0
  • local (host) system: linux, phpunit version 4.8.23
  • vagrant (guest) system: phpunit version 5.1.3 (installed with sudo apt-get install -y phpunit in {project-root}/after.sh)

phpunit would work when called on my local system, but not inside vagrant vm. Inside the vm it would fail with the message PHP Fatal error: Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable.

After changing composer.json to the below and running composer update, everything works fine again. Remember that I didn't touch my installed phpunit versions.

Update composer.json:

"require-dev": {
   [...]
   "phpunit/phpunit": "~5.0", 
   [...]
}

then run

composer update

Thanks for your hints. Helped me a lot.

@acidjazz

This comment has been minimized.

Show comment
Hide comment
@acidjazz

acidjazz Mar 9, 2017

Contributor

@GrahamCampbell another example of why this issue still exists, people still running into it way after you've closed this. I even have this duplicated with phpunit 6

Contributor

acidjazz commented Mar 9, 2017

@GrahamCampbell another example of why this issue still exists, people still running into it way after you've closed this. I even have this duplicated with phpunit 6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment