简体   繁体   中英

Laravel dd helper function returns error 500

I wanted to dd('string') but it's returning error 500. My error_log is:

strpos(): Empty needle {"exception":"[object] (ErrorException(code: 0): strpos(): Empty needle at /vendor/symfony/var-dumper/Dumper/ContextProvider/SourceContextProvider.php:101)

Only dd and dump not working, not other helper functions. it was working properly on local but when I uploaded it to the server it won't anymore, I guess the problem is from php-fpm maybe as this stack link mentions.

How can I figure out where the problem is from?

looks like a bug in Symfony's VarDumper component , in /vendor/symfony/var-dumper/Dumper/ContextProvider/SourceContextProvider.php near line 101, replace

    if (null !== $this->projectDir) {
        $context['project_dir'] = $this->projectDir;
        if (0 === strpos($file, $this->projectDir)) {
            $context['file_relative'] = ltrim(substr($file, \strlen($this->projectDir)), \DIRECTORY_SEPARATOR);
        }
    }

with

    if (isset($this->projectDir) && is_string($this->projectDir) && strlen($this->projectDir) > 0) {
        $context['project_dir'] = $this->projectDir;
        if (0 === strpos($file, $this->projectDir)) {
            $context['file_relative'] = ltrim(substr($file, \strlen($this->projectDir)), \DIRECTORY_SEPARATOR);
        }
    }

that should fix it.

someone should also file a bugreport so it gets fixed upstream.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM