无法打开流:在 Homestead 环境中没有这样的文件或目录

Posted

技术标签:

【中文标题】无法打开流:在 Homestead 环境中没有这样的文件或目录【英文标题】:failed to open stream: No such file or directory on Homestead environment 【发布时间】:2017-09-14 03:06:34 【问题描述】:

我正在使用宅基地环境和命令行“php artisan -V”它不起作用。我用“laravel new test”创建了我的项目,所以..我想我的所有文件都已更新。

vagrant@homestead:~/Laracasts/test$ php artisan -V
PHP Warning:  require(/home/vagrant/Laracasts/test/bootstrap/autoload.php):         
failed to open stream: No such file or directory in         
/home/vagrant/Laracasts/test/artisan on line 16

Warning: require(/home/vagrant/Laracasts/test/bootstrap/autoload.php):     
failed to open stream: No such file or directory in 
/home/vagrant/Laracasts/test/artisan on line 16
PHP Fatal error:  require(): Failed opening required 
'/home/vagrant/Laracasts/test/bootstrap/autoload.php' 
(include_path='.:/usr/share/php') in /home/vagrant/Laracasts/test/artisan on 
line 16

Fatal error: require(): Failed opening required 
'/home/vagrant/Laracasts/test/bootstrap/autoload.php' 
(include_path='.:/usr/share/php') in /home/vagrant/Laracasts/test/artisan on 
line 16
vagrant@homestead:~/Laracasts/test$

.yaml 文件


ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
- ~/.ssh/id_rsa

folders:
- map: ~/Desktop/Arnau/dev/repositories/phpmyadmin
  to: /home/vagrant/phpmyadmin

- map: ~/Desktop/Arnau/dev/repositories/Laravel
  to: /home/vagrant/Laravel

- map: ~/Desktop/Arnau/dev/repositories/Laracasts
  to: /home/vagrant/Laracasts

sites:
- map: phpmyadmin.app
  to: /home/vagrant/phpmyadmin

- map: administracio.dev
  to: /home/vagrant/Laravel/administracio/public

- map: laracasts.dev
  to: /home/vagrant/Laravel/laracasts/public

databases:
- phpmyadmin
- administracio
- laracasts

而且.. 甚至我最后添加的主机文件。

192.168.10.10 administracio.dev
192.168.10.10 laracasts.dev

php composer.phar 安装后的下一个错误

vagrant@homestead:~/Laracasts/test$ php composer.phar install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postInstall
> php artisan optimize
PHP Warning:  require(/home/vagrant/Laracasts/test/bootstrap/autoload.php):     
failed to open stream: No such file or directory in     
/home/vagrant/Laracasts/test/artisan on line 16

Warning: require(/home/vagrant/Laracasts/test/bootstrap/autoload.php): 
failed to open stream: No such file or directory in 
/home/vagrant/Laracasts/test/artisan on line 16
PHP Fatal error:  require(): Failed opening required 
'/home/vagrant/Laracasts/test/bootstrap/autoload.php' 
(include_path='.:/usr/share/php') in /home/vagrant/Laracasts/test/artisan on 
line 16

Fatal error: require(): Failed opening required     
'/home/vagrant/Laracasts/test/bootstrap/autoload.php' 
(include_path='.:/usr/share/php') in /home/vagrant/Laracasts/test/artisan on 
line 16
Script php artisan optimize handling the post-install-cmd event returned 
with error code 255
vagrant@homestead:~/Laracasts/test$

【问题讨论】:

你也可以发布你的 homestead.yaml 文件吗? 我添加了更多信息 尝试在测试项目的根目录下运行 composer install。我猜作曲家还没有编译自动加载器。 我使用了在这里找到的命令行安装:getcomposer.org/download 使用 Composer 下载的所有设置都正确... Composer(1.4.1 版)已成功安装到:/home/vagrant/Laracasts /test/composer.phar 使用它: php composer.phar vagrant@homestead:~/Laracasts/test$ php -r "unlink('composer-setup.php');" vagrant@homestead:~/Laracasts/test$ 但还是一样的错误。 你有运行作曲家吗?进入php composer.phar install 类型的目录,看看是否有帮助。 【参考方案1】:

经过长时间的讨论和调试,问题变得清晰了; bootstrap/autoload.php 文件丢失。

解决此问题的方法是插入本应存在的代码 (found in bootstrap/autoload.php here)。

但文件丢失的原因尚不清楚。

【讨论】:

标记为链接已失效,因此不再回答问题

以上是关于无法打开流:在 Homestead 环境中没有这样的文件或目录的主要内容,如果未能解决你的问题,请参考以下文章

在 PHP 中保存文件时出现问题(“无法打开流:没有这样的文件或目录”)

PHP - 无法打开流:没有这样的主机是已知的

无法打开流:[重复]中没有这样的文件或目录

PHP警告:无法打开流:没有这样的文件或目录,文件路径错误

Require_once 无法打开流:没有这样的文件或目录

要求(供应商/autoload.php):无法打开流:没有这样的文件或目录