Hello everyone, today I will show you a little trick that I use frequently in my scripts to create a Laravel application key commonly generated with artisan.
It's simple, with the help of the openssl package we can generate a random string of 32 characters and at the same time, it can be encoded in base64.
This will generate a fully valid laravel application key that you can use in your
.env configuration file.
echo "base64:$(openssl rand -base64 32)"
Thanks for reading this little tip, don't forget to share it on your social networks or with your development team.
We read soon.
Top comments (3)
Just in-case if need a PHP version:
Hi, thanks for sharing this tip. Just curious about the reason behind it? Or is it just another way to do it?
On one occasion I had to do it this way to generate a secret file in a Laravel application in Kubernetes. Obviously this is another way to do it without having the PHP interpreter installed locally. However you do it, the result is the same.