Comments (22)
I had the same issue. (Using Laravel 5.2)
The problem was that i had a newer version of phpunit installed globally (5.4.4).
So by running phpunit
command the global one was used.
Solutions:
- Use
./vendor/bin/phpunit
instead; - Downgrade the global phpunit, after which you can use the
phpunit
command regularly.
composer global remove phpunit/phpunit
composer global require 'phpunit/phpunit=~4.0'
Or just don't globally require PHPUnit.
Hope somebody finds this useful.
from laravel-exceptions.
Did you make sure to run php artisan config:cache
?
from laravel-exceptions.
It is the other way around:
$app->singleton(
Illuminate\Foundation\Exceptions\Handler::class,
GrahamCampbell\Exceptions\ExceptionHandler::class
);
from laravel-exceptions.
from laravel-exceptions.
So https://github.com/tkprocat/laravel-test-error/blob/master/bootstrap/app.php should be set up correctly?
That is currently giving an error when running phpUnit on the it.
from laravel-exceptions.
I can't replicate. It must be something wrong in your app.
from laravel-exceptions.
Also, make sure you use phpunit 4, laravel isn't compatible with phpunit 5.
from laravel-exceptions.
I'm running 4.8.21 under homestead.
Did you clone it and not get an error while running phpUnit?
from laravel-exceptions.
I use my own package in lots of projects both with phpunit 4 and 5, and it works just fine.
from laravel-exceptions.
Did you correctly install the package?
from laravel-exceptions.
You need to add the service provider near the top of the list of service providers, AND run php artisan config:cache
, as needed every time you modify any config in laravel, AND run php artisan optimize --force
to ensure your compiled.php file is up-to-date.
from laravel-exceptions.
I tried your description above and it didn't help anything. Just to test that the package was installed correctly I made a dummy exception route and it shows the page with id and it gets logged.
Just to be sure I've set things up correctly, can you give me a walkthrough of what needs to be changed on a freshly copy of laravel 5.2? Then I'll make a new project again tomorrow and remake the test to see if that helps.
from laravel-exceptions.
I’ve got this error on several Laravel 5.1 projects. I’ve followed every step suggested here, the service provider is the first called in the list and I’m using whoops 2.0 if it helps narrow the issue. Is there something else that could help you find the culprit?
It’s a great package by the way, thanks for the hard work. 👍
from laravel-exceptions.
Yes, I’ve ran every command listed here.
Here’s my list of providers minus those listed with the default Laravel install:
'providers' => [
GrahamCampbell\Exceptions\ExceptionsServiceProvider::class,
Collective\Html\HtmlServiceProvider::class,
Intervention\Image\ImageServiceProvider::class,
Mews\Purifier\PurifierServiceProvider::class,
Maatwebsite\Excel\ExcelServiceProvider::class,
Barryvdh\Debugbar\ServiceProvider::class,
Spatie\LaravelAnalytics\LaravelAnalyticsServiceProvider::class,
]
My entire app\Exceptions\Handler
:
<?php
namespace App\Exceptions;
use Exception;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use GrahamCampbell\Exceptions\ExceptionHandler as ExceptionHandler;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $dontReport = [
HttpException::class,
ModelNotFoundException::class,
];
/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @return void
*/
public function report(Exception $e)
{
return parent::report($e);
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
if ($e instanceof ModelNotFoundException) {
$e = new NotFoundHttpException($e->getMessage(), $e);
}
return parent::render($request, $e);
}
}
And my composer.json
requires:
"require": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
"laravelcollective/html": "~5.1",
"intervention/image": "2.1.*",
"maatwebsite/excel": "~2.0.0",
"guzzlehttp/guzzle": "~5.0",
"mews/purifier": "~2.0",
"spatie/laravel-analytics": "^1.1",
"league/csv": "^8.0"
},
"require-dev": {
"graham-campbell/exceptions": "~8.1",
"fzaninotto/faker": "~1.5",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1",
"barryvdh/laravel-debugbar": "^2.1"
},
from laravel-exceptions.
use GrahamCampbell\Exceptions\ExceptionHandler as ExceptionHandler;
You can drop the as ExceptionHandler
.
"graham-campbell/exceptions": "~8.1",
This absolutely MUST NOT go into require-dev. It MUST go in require
, however, you should add whoops in require dev.
from laravel-exceptions.
if ($e instanceof ModelNotFoundException) { $e = new NotFoundHttpException($e->getMessage(), $e); }
This code should be removed because this package already does that.
from laravel-exceptions.
Infact, you might as well just delete your exception handler, and bind ours in your bootstrap file.
from laravel-exceptions.
😑 Ok this is weird because I have many projects using your package and this is the only one where I made the mistake of putting it on the require-dev and forgot to add whoops.
So, my bad, but it doesn’t seems to be the issue here: it still gives me the error Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable.
when running phpunit.
Also:
if ($e instanceof ModelNotFoundException) { $e = new NotFoundHttpException($e->getMessage(), $e); }
This code should be removed because this package already does that.
This is the exact same code from the latest Laravel 5.1 branch. Maybe the readme should be updated then?
And:
Infact, you might as well just delete your exception handler, and bind ours in your bootstrap file.
How should I do that exactly? Should I replace this with this:
$app->singleton(
GrahamCampbell\Exceptions\ExceptionsServiceProvider::class,
App\Exceptions\Handler::class
);
from laravel-exceptions.
How should I do that exactly? Should I replace this with this:
it's not working because you've setup the bindings wrong. You MUST leave the illuminate contract in.
from laravel-exceptions.
$app->singleton('Illuminate\Contracts\Debug\ExceptionHandler', 'GrahamCampbell\Exceptions\ExceptionHandler');
from laravel-exceptions.
I finally managed to make it work: it seems to be a problem with Phpunit versions: I had a global 5.2 phpunit while my project was using a 4.x version.
from laravel-exceptions.
@mihailomisic useful ! think you
from laravel-exceptions.
Related Issues (20)
- 500 server error returned as text/plain HOT 2
- r
- How to use? HOT 1
- [9.4] No available `$exception->getMessage()` in views HOT 3
- Support request for Laravel Framework 5.6 HOT 3
- Issues with countables?
- Translate text HOT 4
- Laravel 5.8 HOT 6
- Cannot access the web site. HOT 1
- Does not record the exceptions in the telescope tab exceptions / Laravel 5.8 HOT 3
- Ignition support HOT 1
- Laravel 7 Support HOT 2
- PHP Fatal error: Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [GrahamCampbell\Exceptions\Identifier\IdentifierInterface] is not instantiable. HOT 4
- Not able to handle 500 error through handler HOT 10
- Laravel 6 with composer 2 could not found Laravel-Exceptions classes HOT 2
- TypeError: Argument 1 passed to GrahamCampbell\\Exceptions\\Filter\\VerboseFilter::__construct() must be of the type bool, string given HOT 8
- Able to configure placeholder 'Houston, We Have A Problem.' in InformationMerger or ability to override implementation HOT 3
- Breaks self rendering exceptions (contains render method) HOT 6
- Is it compatible with Laravel Nova? HOT 2
- Target [GrahamCampbell\Exceptions\Identifier\IdentifierInterface] is not instantiable. HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-exceptions.