如何在Laravel项目中添加新的APP_KEY?

时间:2016-12-21 17:13:10

标签: php laravel

我最近正在阅读这篇Stack Overflow帖子

When to generating a New Application Key in Laravel?

同事提到你可以运行:

php artisan key:generate

这将为您克隆的Laravel项目生成一个新的APP_KEY。这在合作和使用Github进行版本控制时是一个合理的问题,但是,当我尝试运行该命令时,我收到了这个错误:

ldco2016@DCortes-MacBook-Pro-3 ~/Projects/photogallery (master)$ php artisan key:generate                                                                [ruby-2.2.1]
PHP Warning:  require(/Users/ldco2016/Projects/photogallery/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /Users/ldco2016/Projects/photogallery/bootstrap/autoload.php on line 17
PHP Stack trace:
PHP   1. {main}() /Users/ldco2016/Projects/photogallery/artisan:0
PHP   2. require() /Users/ldco2016/Projects/photogallery/artisan:16

Warning: require(/Users/ldco2016/Projects/photogallery/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /Users/ldco2016/Projects/photogallery/bootstrap/autoload.php on line 17

Call Stack:
    0.0002     240112   1. {main}() /Users/ldco2016/Projects/photogallery/artisan:0
    0.0003     242776   2. require('/Users/ldco2016/Projects/photogallery/bootstrap/autoload.php') /Users/ldco2016/Projects/photogallery/artisan:16

PHP Fatal error:  require(): Failed opening required '/Users/ldco2016/Projects/photogallery/bootstrap/../vendor/autoload.php' (include_path='.:') in /Users/ldco2016/Projects/photogallery/bootstrap/autoload.php on line 17
PHP Stack trace:
PHP   1. {main}() /Users/ldco2016/Projects/photogallery/artisan:0
PHP   2. require() /Users/ldco2016/Projects/photogallery/artisan:16

Fatal error: require(): Failed opening required '/Users/ldco2016/Projects/photogallery/bootstrap/../vendor/autoload.php' (include_path='.:') in /Users/ldco2016/Projects/photogallery/bootstrap/autoload.php on line 17

Call Stack:
    0.0002     240112   1. {main}() /Users/ldco2016/Projects/photogallery/artisan:0
    0.0003     242776   2. require('/Users/ldco2016/Projects/photogallery/bootstrap/autoload.php') /Users/ldco2016/Projects/photogallery/artisan:16

所以它不那么简单,没有错误。在处理克隆的Laravel项目时,有谁可以帮助生成新的APP_KEY?

1 个答案:

答案 0 :(得分:1)

您必须首先安装composer并运行gdb ./a.out core,以便laravel可以访问命令。