Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

laravel 4: key not being generated with artisan

When running

php artisan key:generate

I can see the generated key in my shell, but the variable 'key' in app.php remains empty.

Running on localhost with windows-apache-php 5.4 - mysql.

Never had this problem before with laravel 4 beta version.

like image 920
kriek Avatar asked May 29 '13 16:05

kriek


People also ask

Why is Artisan not working php?

Reasons why php artisan serve not workingYou are running php artisan serve command in wrong directory. php artisan serve is laravel command only work with laravel project. Check project directory and run in root directory of your project. The requested host or port is not available.

What is php artisan key generate?

php artisan key:generate is a command that sets the APP_KEY value in your . env file. By default, this command is run following a composer create-project laravel/laravel command.

How can I get Laravel APP key?

The easiest way to generate the key is by using the artisans' command. After this, the APP_KEY value is automatically set in the . env file for you to use it later on. It is used to encrypt the files in your application.

What does Laravel Artisan do?

Laravel Artisan is one of the three command line interfaces found in the Laravel framework. It is a helpful command line interface, assisting developers into developing applications though the numerous easy to read commands. One can also create custom codes in order to increase the efficiency of the applications.


2 Answers

Had the same problem ...

  1. Opened app.php
  2. Remove the entry that says 'YourSecretKey!!!'
  3. Ran 'php artisan key:generate'

Showed me a key in the console, but nothing in app.php!

Solution is ... unlike Laravel 3, don't delete the default YourSecretKey!!! in app.php, just run the command and it will work.

Hope this helps.

Bagwaa

like image 128
Richard Bagshaw Avatar answered Sep 20 '22 12:09

Richard Bagshaw


You should not remove the original key, just go to your project directory and run

php artisan key:generate

it will work if you don't touch the previous key.

like image 41
Iman Mohamadi Avatar answered Sep 23 '22 12:09

Iman Mohamadi