Skip to content
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

Function name must be a string #20

Closed
aftabnaveed opened this issue Jun 4, 2018 · 8 comments
Closed

Function name must be a string #20

aftabnaveed opened this issue Jun 4, 2018 · 8 comments

Comments

@aftabnaveed
Copy link

aftabnaveed commented Jun 4, 2018

in my laravel 5.6 application I am getting a strange error on every request.

What is possibaly going wrong here?

Symfony\Component\Debug\Exception\FatalThrowableError thrown with message "Function name must be a string"

Stacktrace:
#6 Symfony\Component\Debug\Exception\FatalThrowableError in /srv/site-laravel/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:152
#5 LaravelFly\Server\HttpServer:onRequest in /srv/site-laravel/vendor/scil/laravel-fly/src/LaravelFly/Server/HttpServer.php:0
#4 Swoole\Http\Server:start in /srv/site-laravel/vendor/scil/laravel-fly/src/LaravelFly/Server/Common.php:273
#3 LaravelFly\Server\HttpServer:start in /srv/site-laravel/vendor/scil/laravel-fly/src/LaravelFly/Server/HttpServer.php:26
#2 LaravelFly\Server\HttpServer:start in /srv/site-laravel/vendor/scil/laravel-fly/src/LaravelFly/Fly.php:70
#1 LaravelFly\Fly:start in /srv/site-laravel/vendor/scil/laravel-fly/bin/fly:78
#0 {main} in /srv/site-laravel/vendor/scil/laravel-fly/bin/fly:0
@scil
Copy link
Owner

scil commented Jun 4, 2018

could you find more details?

use xdebug?

Or set 'tinker' => true, in fly.conf.php and add eval(tinker()) ?

@aftabnaveed
Copy link
Author

I already have the xdebug enabled, otherwise PHP won't print the stack trace :)

@scil Where should I add eval(tinker()) ?

Thanks.

@scil
Copy link
Owner

scil commented Jun 4, 2018

eval(tinker()) can be placed everywhere almost.

open https://github.com/scil/LaravelFly and click "tinker use examples.(🎃 click me!)",
there are some examples.

@aftabnaveed
Copy link
Author

OK thanks, I figured it out and tried, but it would take me some time to use it properly. The error seems to be associated with a middleware. I will try to use xdebug to see the problem.

@aftabnaveed
Copy link
Author

Ok I got a bit closer to the issue. I have a named middleware that I registered in App/Http/Kernel.php. The trouble is when it gets to the Line 152 of Illuminate\Pipeline\Pipeline it for some reason is not able to obtain its class thus causing the error.

My current application is perfectly working fine with default PHP-FPM setup.

 $response = method_exists($pipe, $this->method)
                                ? $pipe->{$this->method}(...$parameters)
                                : $pipe(...$parameters);

@scil
Copy link
Owner

scil commented Jun 4, 2018

Can I read your middleware code?

or have you changed ``class Kernel extends HttpKernel ` in app/Http/Kernel.php like https://github.com/scil/LaravelFly/blob/master/doc/config.md ?

@aftabnaveed
Copy link
Author

OK this code fixed the issue in App\Http\Kernel.php:

if (defined('LARAVELFLY_MODE')) {
    if (LARAVELFLY_MODE == 'Map') {
        class WhichKernel extends \LaravelFly\Map\Kernel { }
    }elseif (LARAVELFLY_MODE == 'Simple') {
        class WhichKernel extends \LaravelFly\Simple\Kernel { }
    } elseif (LARAVELFLY_MODE == 'FpmLike') {
        class WhichKernel extends HttpKernel{}
    } else {
        class WhichKernel extends \LaravelFly\Greedy\Kernel { }
    }
} else {
    class WhichKernel extends HttpKernel { }
}

Thanks

@scil
Copy link
Owner

scil commented Jun 4, 2018

nice!

You can also define an new Kernel file only for LaravelFly and replace \App\Http\Kernel::class with its name in fly.conf.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants