在命令行上运行 Artisan (Laravel) 时出现致命错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11008610/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Fatal Error While Running Artisan (Laravel) on Command Line
提问by Graham Kennedy
I am experiencing a fatal error while using artisan on the (fantastic) Laravel PHP framework.
我在(很棒的)Laravel PHP 框架上使用 artisan 时遇到了致命错误。
I recently downloaded v3.2.1 of Laravel, and I tried running the following command line from within the directory that artisan resides:
我最近下载了 Laravel 的 v3.2.1,并尝试从 artisan 所在的目录中运行以下命令行:
php artisan key:generate
This should create a random key for me in my applications/application.php file. (Please see http://laravel.com/docs/artisan/commandsfor a specific reference to this command.)
这应该在我的 applications/application.php 文件中为我创建一个随机密钥。(有关此命令的具体参考,请参阅http://laravel.com/docs/artisan/commands。)
However, when I run this command from the shell I receive the following error:
但是,当我从 shell 运行此命令时,我收到以下错误:
Warning: chdir(): No such file or directory (errno 2) in /home/[USERNAME REMOVED]/websites/[DIRECTORY REMOVED]/htdocs/dev/sb4/paths.php on line 62
Parse error: syntax error, unexpected T_STRING in /home/[USERNAME REMOVED]/websites/[DIRECTORY REMOVED]/htdocs/dev/sb4/laravel/core.php on line 1
This is what's on line 62 of paths.php:
这是paths.php第62行的内容:
chdir(__DIR__);
This is what's on line 1 of core.php:
这是 core.php 第 1 行的内容:
<?php namespace Laravel;
My question is this: Are there any specific environment, directory, or other permissions that I should modify to get artisan up and running.
我的问题是:是否有任何特定的环境、目录或其他权限我应该修改以启动和运行 artisan。
A little background:
一点背景:
- I installed Laravel 3.2.1 yesterday for the first time
- I can run a simple web application successfully on my system (i.e. I can route a request to a controller and load up the associated blade properly)
- I simply downloaded the Laravel 3.2.1 (laravel-laravel-v3.2.1-8-gaae8b62.zip) from GitHub and extracted it on my server
- 我昨天第一次安装了 Laravel 3.2.1
- 我可以在我的系统上成功运行一个简单的 Web 应用程序(即我可以将请求路由到控制器并正确加载相关的刀片)
- 我只是从 GitHub 下载了 Laravel 3.2.1 (laravel-laravel-v3.2.1-8-gaae8b62.zip) 并将其解压缩到我的服务器上
My environment:
我的环境:
- PHP 5.3.13 on a shared host at Dreamhost
- FireSSH to run the commands
- Dreamhost 共享主机上的 PHP 5.3.13
- FireSSH 来运行命令
My root directory: (permissions in parenthesis)
我的根目录:(括号内为权限)
- /application (775)
- /bundles (775)
- /laravel (775)
- /public (775)
- /storage (775)
- /artisan (664)
- /paths.php (777)
- /申请 (775)
- /捆绑 (775)
- /laravel (775)
- /公共 (775)
- / 存储 (775)
- /工匠 (664)
- /paths.php (777)
Please let me know if there are any other details about my setup that relevant. I'm really not sure what will help in troubleshooting this issue.
请让我知道是否有任何其他有关我的设置的详细信息。我真的不确定什么有助于解决这个问题。
--
——
UPDATE: I also posted this issue to Laravel's GitHub issue tracker. (https://github.com/laravel/laravel/issues/820)
更新:我也将此问题发布到 Laravel 的 GitHub 问题跟踪器。(https://github.com/laravel/laravel/issues/820)
回答by Graham Kennedy
First off, thanks @KingCrunch, your first response led me down the correct path toward resolving this issue. Additionally, I received an excellent response from Dreamhost technical support (specifically Gary S), who gave me the concise answer I was looking for.
首先,感谢@KingCrunch,您的第一个回复让我走上了解决这个问题的正确道路。此外,我收到了 Dreamhost 技术支持(特别是 Gary S)的出色回复,他给了我我正在寻找的简洁答案。
The issue was: I was running PHP 5.2.17 at the CLI, whereas my web server was running PHP 5.3.13.
问题是:我在 CLI 上运行 PHP 5.2.17,而我的 Web 服务器运行 PHP 5.3.13。
The resolution is: Use
决议是:使用
/usr/local/php53/bin/php artisan <command>
when running artisan commands at the CLI. This will ensure that all of my artisan commands are run using PHP 5.3 and above, which satisfies Laravel's PHP 5.3+ requirements.
在 CLI 中运行 artisan 命令时。这将确保我所有的 artisan 命令都使用 PHP 5.3 及更高版本运行,满足 Laravel 的 PHP 5.3+ 要求。
回答by KingCrunch
Namespaces and the __DIR__
-pseud-constant were introduced in PHP 5.3. It seems you are running an old version. You should update to at least 5.3.
命名空间和__DIR__
-pseud-constant 是在 PHP 5.3 中引入的。看来您运行的是旧版本。您应该至少更新到 5.3。
php -v