Laravel php artisan tinker引发错误异常
如果在控制台上运行php artisan tinker,则输出为: [ErrorException] in_array() expects parameter 2 to be array, string given 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 php artisan tinker引发错误异常,php,laravel,laravel-artisan,Php,Laravel,Laravel Artisan,如果在控制台上运行php artisan tinker,则输出为: [ErrorException] in_array() expects parameter 2 to be array, string given Exception trace: () at C:\wamp\www\store\vendor\psy\psysh\src\Psy\ConfigPaths.php:161 Illuminate\Foundation\Bootstrap\HandleExceptions->hand
我的Laravel版本是5.1.24。
我刚刚安装了
除此之外,该应用程序几乎是空白的
编辑: 以下是configpath.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;
}
提前谢谢 检查C:\wamp\www\store\vendor\psy\psysh\src\psy\ConfigPaths.php上的值这些值似乎有问题,因为当脚本在数组函数中调用时没有得到正确的值检查C:\wamp\www\store\vendor\psy\psysh\src\psy\ConfigPaths.php上的值就像那些值有问题一样,因为当脚本在数组中调用函数时没有得到正确的值这也发生在我身上
执行
composer update
并将包更新为psy/psysh(v0.6.1)修复了该问题。我也遇到了这种情况
执行
composer update
并将程序包更新为psy/psysh(v0.6.1)修复了该问题。您是否尝试过composer dump autoload
或php artisan optimize
?是的,它们在没有响应的情况下运行并完成,问题仍然存在:(您是否尝试过composer dump autoload
或php artisan optimize
?是的,它们运行并完成时没有响应,问题仍然存在:(我知道错误现在发生在哪里,但我不知道为什么。在数组取消移位后,我将函数添加到questionCheck返回的strtr值或check dirs,记住$dirs应该是数组强制in_数组的参数为数组及其工作。这是v0.6.0中的回归,在v0.6.1中修复。只需编写器更新
:)我现在看到了错误发生的地方,但我不知道为什么。我在questionCheck中添加了函数,在数组取消移位后检查strtr的返回值或检查dirs,记住$dirs应该是数组强制in_数组的参数为数组及其工作。这是v0.6.0中的回归,在v0.6.1中修复。只需编写器更新
:)