1

I recently was reading this Stack Overflow post

When to generating a New Application Key in Laravel?

where colleagues mentioned that you can run:

php artisan key:generate

and this will generate a new APP_KEY for your cloned Laravel project. This being a legitimate concern when collaborating and using Github for version control, however, when I tried to run that command I got this error:

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

So its not so straightforward and error free. Can anyone lend a hand as to how to generate a new APP_KEY when working on a cloned Laravel project?

Marek Skiba
  • 2,124
  • 1
  • 28
  • 31
Daniel
  • 14,004
  • 16
  • 96
  • 156
  • 2
    Have you installed composer and run `composer install` yet? – aynber Dec 21 '16 at 17:13
  • @aynber, that's right, its looking for the autoload files and that comes with installing composer. Nice! I am ready to mark your response as the correct answer. – Daniel Dec 21 '16 at 17:16
  • Done. I'm currently doing the same thing on my server, so I recognized the error. :-D – aynber Dec 21 '16 at 17:19

1 Answers1

1

You must first install composer and run composer install so that laravel can access the commands.

aynber
  • 22,380
  • 8
  • 50
  • 63