zeuxisoo/php-slim-whoops

Fatal error: Call to undefined method Closure::getContainer()

carbontwelve opened this issue · 5 comments

Running with slim-whoops version 0.5.* and slim version 3.x-dev (3e35f73).

The 0.5.* version only work on slim version 3.1.* currently. And base on this PR slimphp/Slim#1770, the branch 3.x-dev maybe moving toward 3.2.* development.

But I will find time to solve this issue. thank for your report.

Ooops, I already updated the slim to 3.x-dev branch, then run the test case and examples are passed.

So, i cannot reproduce your issue. Could you mind to post your code or error screenshots to here?

The error stack is as follows:

( ! ) Fatal error: Call to undefined method Closure::getContainer() in C:\xampp\htdocs\DEV\azure-dns\vendor\zeuxisoo\slim-whoops\src\Zeuxisoo\Whoops\Provider\Slim\WhoopsMiddleware.php on line 13
Call Stack
#   Time    Memory  Function    Location
1   0.2170  131392  {main}( )   ...\serve.php:0
2   0.2190  140504  require_once( 'C:\xampp\htdocs\DEV\azure-dns\public\index.php' )    ...\serve.php:43
3   0.3250  1879504 Slim\App->run( )    ...\index.php:32
4   0.3500  2411784 Slim\App->process( )    ...\App.php:294
5   0.3500  2411864 Slim\App->callMiddlewareStack( )    ...\App.php:333
6   0.3500  2411920 Slim\App->Slim\{closure}( ) ...\MiddlewareAwareTrait.php:116
7   0.3500  2411952 call_user_func:{C:\xampp\htdocs\DEV\azure-dns\vendor\slim\slim\Slim\MiddlewareAwareTrait.php:67} ( )    ...\MiddlewareAwareTrait.php:67
8   0.3500  2412032 Slim\DeferredCallable->__invoke( )  ...\MiddlewareAwareTrait.php:67
9   0.3520  2424792 call_user_func_array:{C:\xampp\htdocs\DEV\azure-dns\vendor\slim\slim\Slim\DeferredCallable.php:37} ( )  ...\DeferredCallable.php:37
10  0.3520  2425312 Zeuxisoo\Whoops\Provider\Slim\WhoopsMiddleware->__invoke( ) ...\DeferredCallable.php:37

It's within this branch of my azure-dns tool.

Thank for your code, I reviewed your whoops branch and reproduced this issue.

In your program, please ensure the slim-whoops was first added to middleware stack.

like:

use Zeuxisoo\Whoops\Provider\Slim\WhoopsMiddleware;

$app->add(new WhoopsMiddleware);
$app->add(new OtherMiddleware1);
$app->add(new OtherMiddleware2);

NOT like:

use Zeuxisoo\Whoops\Provider\Slim\WhoopsMiddleware;

$app->add(new OtherMiddleware1);
$app->add(new OtherMiddleware2);
$app->add(new WhoopsMiddleware);

Ah, how did I not see that at the time. Thank you.