【发布时间】:2019-11-13 09:37:01
【问题描述】:
升级我的 Homestead 并安装我的软件包后,我遇到了一个奇怪的错误。在调用php artisan 时,输出如下:
In LoadConfiguration.php line 68:
Unable to load the "app" configuration file.
一些人suggest 认为这是 Windows (10) 将文件名大写的原因。但是,这在我的文件夹中看不到,也不适用于我的 Ubuntu (18.04) 环境。
查看LoadConfiguration.php的源代码,我们可以看到它使用了symfony/finder组件中的Finder类。
foreach (Finder::create()->files()->name('*.php')->in($configPath) as $file) {
$directory = $this->getNestedDirectory($file, $configPath);
$files[$directory.basename($file->getRealPath(), '.php')] = $file->getRealPath();
}
问题是查找器确实返回了一个无法找到我的配置文件的迭代器。一个简单的scandir($configPath) 返回所有文件:
.
..
app.php
and all other files
将调用包装在iterator_to_array() 中会返回一个空数组[]。
添加..->in($configPath)->getIterator()返回以下对象:
Symfony\Component\Finder\Iterator\PathFilterIterator {#47
#matchRegexps: []
#noMatchRegexps: array:2 [
0 => "#(^|/)\..+(/|$)#"
1 => "#(^|/)\..+(/|$)#"
]
innerIterator: Symfony\Component\Finder\Iterator\FilenameFilterIterator {#43
#matchRegexps: array:1 [
0 => "#^(?=[^\.])[^/]*\.php$#"
]
#noMatchRegexps: []
innerIterator: Symfony\Component\Finder\Iterator\FileTypeFilterIterator {#39
-mode: 1
innerIterator: RecursiveIteratorIterator {#42
innerIterator: Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator {#46
-iterator: Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator {#48
-ignoreUnreadableDirs: false
-rewindable: null
-rootPath: "/home/vagrant/somepath/api/config"
-subPath: null
-directorySeparator: "/"
path: "/home/vagrant/somepath/api/config"
filename: "app.php"
basename: "app.php"
pathname: "/home/vagrant/somepath/api/config/app.php"
extension: "php"
realPath: "./config/app.php"
aTime: 2019-07-02 09:28:30
mTime: 2019-01-31 17:43:49
cTime: 2019-07-02 16:32:52
inode: 429
size: 9727
perms: 0100777
owner: 1000
group: 1000
type: "file"
writable: true
readable: true
executable: true
file: true
dir: false
link: false
}
-isRecursive: true
-excludedDirs: array:9 [
".svn" => true
"_svn" => true
"CVS" => true
"_darcs" => true
".arch-params" => true
".monotone" => true
".bzr" => true
".git" => true
".hg" => true
]
-excludedPattern: null
innerIterator: Symfony\Component\Finder\Iterator\RecursiveDirectoryIterator {#48}
}
}
}
}
}
假设我对这些类型的迭代器一无所知。有两点让我印象深刻:
- 有很多
innerIterator存在。 - 一个迭代器可以找到
#48的东西,我们可以看到我们的config/app.php,但在ExcludeDirectoryFilterIterator内。
以前有没有人遇到过这个问题或知道如何引导我走向正确的方向?
使用了以下版本:
OS: Windows 10/Ubuntu 18.04 LTS
Homestead: 9.0.1
laravel/framework: 5.8.*/5.7.*
\ symfony/finder: ^4.2/^4.1,
编辑
将我的 Homestead 降级为 v8.0.1,一切正常。但是仍然没有解释为什么会在v9.0.1 上发生这种情况。
【问题讨论】:
-
你升级 Laravel 了吗?
-
是的,我测试了
4.1和symfony/finder附带的5.7和5.8。 -
我在两天前将我的 Homestead vagrant box 更新到 v8.0.0 并将我的 Homestead 源代码更新到 v9.0.1 时遇到了同样的问题,从那以后我一直在苦苦挣扎。这是在 Windows 10 / Ubuntu 18.04.2 LTS / Laravel 5.6.26 / Finder 4.3.2 上。 @ThomasVanderVeen 您的 Homestead 盒子 (
vagrant box list) 是什么版本?另外,您是否通过运行git fetch --all然后运行 git checkout tags/v8.0.1 -b release来降级您的 Homestead 源代码? -
@w5m 当前运行的盒子版本
7.0.1带有虚拟盒子。我确实跑了git checkout v8.0.1 -
可能与
case-sensitive有关。请同时检查文件的大小写。
标签: php laravel symfony homestead