Laravel php工匠修补匠抛出错误异常

时间:2015-11-12 03:17:44

标签: php laravel artisan

如果我在控制台上运行 php artisan tinker ,则输出为:

[ErrorException]
in_array() expects parameter 2 to be array, string given

如果我运行 php artisan tinker --verbose ,则输出为:

Exception trace:
 () at C:\wamp\www\store\vendor\psy\psysh\src\Psy\ConfigPaths.php:161
 Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() at n/a:n/a
 in_array() at C:\wamp\www\store\vendor\psy\psysh\src\Psy\ConfigPaths.php:161
 Psy\ConfigPaths::getDirNames() at C:\wamp\www\store\vendor\psy\psysh\src\Psy\ConfigPaths.php:35
 Psy\ConfigPaths::getConfigDirs() at C:\wamp\www\store\vendor\psy\psysh\src\Psy\ConfigPaths.php:89
 Psy\ConfigPaths::getConfigFiles() at C:\wamp\www\store\vendor\psy\psysh\src\Psy\Configuration.php:146
 Psy\Configuration->getConfigFile() at C:\wamp\www\store\vendor\psy\psysh\src\Psy\Configuration.php:117
 Psy\Configuration->init() at C:\wamp\www\store\vendor\psy\psysh\src\Psy\Configuration.php:98
 Psy\Configuration->__construct() at C:\wamp\www\store\vendor\laravel\framework\src\Illuminate\Foundation\Console\TinkerCommand.php:44
 Illuminate\Foundation\Console\TinkerCommand->fire() at n/a:n/a
 call_user_func_array() at C:\wamp\www\store\vendor\laravel\framework\src\Illuminate\Container\Container.php:503
 Illuminate\Container\Container->call() at C:\wamp\www\store\vendor\laravel\framework\src\Illuminate\Console\Command.php:150
 Illuminate\Console\Command->execute() at C:\wamp\www\store\vendor\symfony\console\Command\Command.php:256
 Symfony\Component\Console\Command\Command->run() at C:\wamp\www\store\vendor\laravel\framework\src\Illuminate\Console\Command.php:136
 Illuminate\Console\Command->run() at C:\wamp\www\store\vendor\symfony\console\Application.php:838
 Symfony\Component\Console\Application->doRunCommand() at C:\wamp\www\store\vendor\symfony\console\Application.php:189
 Symfony\Component\Console\Application->doRun() at C:\wamp\www\store\vendor\symfony\console\Application.php:120
 Symfony\Component\Console\Application->run() at C:\wamp\www\store\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php:107
 Illuminate\Foundation\Console\Kernel->handle() at C:\wamp\www\store\artisan:36

附加
我的Laravel版本是5.1.24 我刚刚安装了Zizaco/entrust
除此之外,该应用程序几乎是空白

修改

以下是ConfigPaths.php中错误的函数:

private static function getDirNames(array $baseDirs) {
    $dirs = array_map(function ($dir) {
        return strtr($dir, '\\', '/') . '/psysh';
    }, $baseDirs);

    // Add ~/.psysh
    if ($home = getenv('HOME')) {
        $dirs[] = strtr($home, '\\', '/') . '/.psysh';
    }

    // Add some Windows specific ones :)
    if (defined('PHP_WINDOWS_VERSION_MAJOR')) {
        if ($appData = getenv('APPDATA')) {
            // AppData gets preference
            array_unshift($dirs, strtr($appData, '\\', '/') . '/PsySH');
        }

        $dir = strtr(getenv('HOMEDRIVE') . '/' . getenv('HOMEPATH'), '\\', '/') . '/.psysh';
        if (!in_array($dirs, $dir)) {
            $dirs[] = $dir;
        }
    }

    return $dirs;
}

如果有人遇到同样的问题,请按照以下方法解决问题:

# add (array) before $dir
if (!in_array($dirs, (array)$dir)) {
    $dirs[] = $dir;
}

提前致谢!

2 个答案:

答案 0 :(得分:3)

这也发生在我身上。

执行composer update并将软件包更新到psy / psysh(v0.6.1)修复了问题。

答案 1 :(得分:1)

检查 C:\ wamp \ www \ store \ vendor \ psy \ psysh \ src \ Psy \ ConfigPaths.php 上的值似乎这些值有问题,因为脚本时调用in_array函数没有得到正确的值