As it must comply with the rules of the selected cipher in the configuration, the easiest way to generate a valid key is using the php artisan key:generate -show command, which will print a key that you can copy and then paste into the next step. OS は CentOS 6.7、 PHP は 5.6.24 です。 composer create-project -prefer-dist laravel/laravel test で作成した test ディレクトリに入り、 cd test chmod -R a+w storage/. chmod -R a+w bootstrap/cache php artisan key:generate をした後、 php artisan serve を実行すると.
Introduction
Laravel's encrypter uses OpenSSL to provide AES-256 and AES-128 encryption. You are strongly encouraged to use Laravel's built-in encryption facilities and not attempt to roll your own 'home grown' encryption algorithms. All of Laravel's encrypted values are signed using a message authentication code (MAC) so that their underlying value can not be modified once encrypted.
Configuration
Before using Laravel's encrypter, you must set a key option in your config/app.php configuration file. You should use the php artisan key:generate command to generate this key since this Artisan command will use PHP's secure random bytes generator to build your key. If this value is not properly set, all values encrypted by Laravel will be insecure.
Using The Encrypter
Encrypting A Value
You may encrypt a value using the encrypt helper. All encrypted values are encrypted using OpenSSL and the AES-256-CBC cipher. Furthermore, all encrypted values are signed with a message authentication code (MAC) to detect any modifications to the encrypted string:
Encrypting Without Serialization
Encrypted values are passed through serialize during encryption, which allows for encryption of objects and arrays. Thus, non-PHP clients receiving encrypted values will need to unserialize the data. If you would like to encrypt and decrypt values without serialization, you may use the encryptString and decryptString methods of the Crypt facade:
Decrypting A Value
You may decrypt values using the decrypt helper. If the value can not be properly decrypted, such as when the MAC is invalid, an IlluminateContractsEncryptionDecryptException will be thrown:

Lumen Micro Framework=> php artisan key:generate (8)
1.Open your terminal setup file:
2.Create an alias for generating random strings:
3.Get a key whenever you need:
You can also remove the third step by adding the key directly in .env using PHP.
I'm trying out the PHP micro Framework Lumen (from Laravel).
One of my first steps was to look into the .env.example file and make a copy of it to have my .env file. There is a variable APP_KEY just like there is in Laravel. Now I tried out the simple command php artisan key:generate to get my new key But I ran into the following error message:
[InvalidArgumentException] There are no commands defined in the 'key' namespace.
Does some one know how I can generate keys for Lumen?
Update with solution
Php Artisan Key:generate Error Code
So I found my favorite solution for this problem. On the command line (Linux) I run php -r 'echo md5(uniqid()).'n';' what gives me something like this 7142720170cef01171fd4af26ef17c93 .
If you are going to use Lumen more often, you may want to create an alias in your .bashrc , which is located in your home directory /home/USERNAME . To do so, you can open the file with nano ~/.bashrc or vi ~/.bashrc and copy the following alias at the end of the file, alias phpkey='php -r 'echo md5(uniqid()).'n';' . Now you can use the command phpkey which will give you a 32 character long random string :)
Php Artisan Key:generate Error Codes
All I do on mac is execute this command in the terminal:
Free Keygens Downloads
This copies the value into the clipboard and so you can easily paste the key into the .env file.