php artisan serve - 抛出错误

时间:2017-06-06 13:11:18

标签: php laravel artisan

所以我今天刚开始学习Laravel并安装 Composer Laravel

我使用以下方法创建了一个新的应用程序: -

laravel new application

在我的文件夹中: -

/Library/WebServer/Documents/

但是,当我尝试运行时: -

php artisan serve

我收到此错误: -

Warning: require(/Library/WebServer/Documents/application/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /Library/WebServer/Documents/application/bootstrap/autoload.php on line 17

Fatal error: require(): Failed opening required '/Library/WebServer/Documents/application/bootstrap/../vendor/autoload.php' (include_path='.:') in /Library/WebServer/Documents/application/bootstrap/autoload.php on line 17

我已经尝试过更新我的作曲家,但没有奏效。 我在这里做错了什么?

修改

运行 composer install 会给出: -

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - This package requires php >=5.6.4 but your PHP version (5.5.34) does not satisfy that requirement.
  Problem 2
    - Installation request for laravel/framework v5.4.24 -> satisfiable by laravel/framework[v5.4.24].
    - laravel/framework v5.4.24 requires php >=5.6.4 -> your PHP version (5.5.34) does not satisfy that requirement.
  Problem 3
    - Installation request for phpunit/php-code-coverage 4.0.8 -> satisfiable by phpunit/php-code-coverage[4.0.8].
    - phpunit/php-code-coverage 4.0.8 requires php ^5.6 || ^7.0 -> your PHP version (5.5.34) does not satisfy that requirement.
  Problem 4
    - Installation request for phpunit/phpunit 5.7.20 -> satisfiable by phpunit/phpunit[5.7.20].
    - phpunit/phpunit 5.7.20 requires php ^5.6 || ^7.0 -> your PHP version (5.5.34) does not satisfy that requirement.
  Problem 5
    - Installation request for phpunit/phpunit-mock-objects 3.4.3 -> satisfiable by phpunit/phpunit-mock-objects[3.4.3].
    - phpunit/phpunit-mock-objects 3.4.3 requires php ^5.6 || ^7.0 -> your PHP version (5.5.34) does not satisfy that requirement.
  Problem 6
    - Installation request for sebastian/code-unit-reverse-lookup 1.0.1 -> satisfiable by sebastian/code-unit-reverse-lookup[1.0.1].
    - sebastian/code-unit-reverse-lookup 1.0.1 requires php ^5.6 || ^7.0 -> your PHP version (5.5.34) does not satisfy that requirement.
  Problem 7
    - Installation request for sebastian/environment 2.0.0 -> satisfiable by sebastian/environment[2.0.0].
    - sebastian/environment 2.0.0 requires php ^5.6 || ^7.0 -> your PHP version (5.5.34) does not satisfy that requirement.
  Problem 8
    - Installation request for sebastian/object-enumerator 2.0.1 -> satisfiable by sebastian/object-enumerator[2.0.1].
    - sebastian/object-enumerator 2.0.1 requires php >=5.6 -> your PHP version (5.5.34) does not satisfy that requirement.
  Problem 9
    - Installation request for sebastian/resource-operations 1.0.0 -> satisfiable by sebastian/resource-operations[1.0.0].
    - sebastian/resource-operations 1.0.0 requires php >=5.6.0 -> your PHP version (5.5.34) does not satisfy that requirement.
  Problem 10
    - Installation request for sebastian/version 2.0.1 -> satisfiable by sebastian/version[2.0.1].
    - sebastian/version 2.0.1 requires php >=5.6 -> your PHP version (5.5.34) does not satisfy that requirement.
  Problem 11
    - laravel/framework v5.4.24 requires php >=5.6.4 -> your PHP version (5.5.34) does not satisfy that requirement.
    - laravel/tinker v1.0.1 requires illuminate/console ~5.1 -> satisfiable by laravel/framework[v5.4.24].
    - Installation request for laravel/tinker v1.0.1 -> satisfiable by laravel/tinker[v1.0.1].

2 个答案:

答案 0 :(得分:0)

  

注意:您正在使用laravel 5.4,它需要php 5.6(最低),要么将php更新为5.6或使用laravel 5.2,这就是原因   使用此命令安装laravel 5.2

composer create-project --prefer-dist laravel/laravel your_project_name "5.2.*"

转到命令提示符(在Windows中)

设置www / {ur project}的路径

对我来说:www / laravel5

然后输入以下命令:composer install

它将自动安装vendor /

中的所有依赖项

答案 1 :(得分:0)

您必须使用composer install安装项目的供应商依赖项:

# go to the app root folder
cd /Library/WebServer/Documents/application/
# install vendor dependecies
composer install

修改

在您的问题编辑之后,错误消息清楚地表明您有一个旧的PHP版本无法运行您的新laravel应用程序。您有两种选择:

将您的php升级到php 5.6.25(最好是php7)

降级您的应用(至5.2。*级别,以下脚本将删除它并安装新的

# go to the app root folder
cd /Library/WebServer/Documents/
rm -rf application
# install vendor dependecies
composer create-project --prefer-dist laravel/laravel application 5.2.*
相关问题