Php artisan key:generate not working

i have problem here on PHP 7.4.15
When i run command, it does not write it into .env file, but it says key generated on terminal.
I am on macos Big Sur, M1 silicon

paper git:[vladimir/swap-is_admin] ✗ php artisan key:generate
Application key set successfully.
➜  paper git:[vladimir/swap-is_admin] ✗ php -v
PHP 7.4.15 [cli] [built: Feb  4 2021 07:01:35] [ NTS ]
Copyright [c] The PHP Group
Zend Engine v3.4.0, Copyright [c] Zend Technologies
   with Xdebug v3.0.3, Copyright [c] 2002-2021, by Derick Rethans
   with Zend OPcache v7.4.15, Copyright [c], by Zend Technologies```

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.

tshepang

11.6k21 gold badges90 silver badges134 bronze badges

asked May 29, 2013 at 16:04

1

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

ckpepper02

3,2275 gold badges27 silver badges43 bronze badges

answered May 29, 2013 at 23:44

1

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.

answered Aug 20, 2013 at 13:23

Iman MohamadiIman Mohamadi

6,1892 gold badges33 silver badges33 bronze badges

Have the same problem with L6 on Windows with xampp.

  1. Remove the cached config php artisan config:clear
  2. Regenerate key php artisan key:generate

Hope it helps.

answered Dec 28, 2019 at 11:50

1

The .env file needs to contain a line like this:

APP_KEY=

You don't have to specify a key, but you have to at least provide a .env file and also the above line.

answered Oct 25, 2020 at 17:09

AdamAdam

22.3k20 gold badges131 silver badges213 bronze badges

first type any 32 character like 'hyhyhGGyhyhyhyhy23hyhy23hyhy23hy' this and then re execute the command in terminal/cmd.

Step 1:

go to app ---> Config --> app.php

step 2:

'key' => '10101010101010101010101010101010', type any 32 digit or character in that place.

step 3:

go to terminal / cmd & type : "php artisan key:generate" press enter

step 4:

see the key has been changed :]

[ It is because in Laravel 4 By using "php artisan key:generate" we simply can replace the default key any time. But if it is an empty space it can not be able to hold the place. ]

Enjoy coding :] \m/

answered Aug 31, 2013 at 5:05

0

The key generator will only update the APP_KEY in the .env file.

'key' => env['APP_KEY', 'YourSecretKey'], 

config/app.php this is reading the APP_KEY from your .env file. The second parameter is a fallback.

answered Sep 30, 2015 at 8:48

John MagnoliaJohn Magnolia

16.2k33 gold badges152 silver badges261 bronze badges

Follow this simple steps:

  1. Remove the cached config php artisan config:clear
  2. Remove existing key or ensure that you have this line : APP_KEY= on your .env file.
  3. Regenerate key php artisan key:generate

Dharman

27.7k21 gold badges75 silver badges126 bronze badges

answered May 5, 2021 at 11:49

Jerry OkaforJerry Okafor

3,5703 gold badges16 silver badges25 bronze badges

I was having the same issue. From my project directory I noticed I had the .env file, when I opened the project in atom [my code editor] I noticed that file appeared as .env.txt, I removed the .txt part and ran the command. It worked for me.

answered Jun 13, 2017 at 13:10

FNunezFNunez

982 silver badges12 bronze badges

Chủ Đề