Php Artisan Key Generate In Laravel
Php artisan key:generate. 报错1:PHP脚本占用内存太多,memorylimit默认128m不够用。 PHP Fatal error: Allowed memory size of XXXXXX bytes exhausted 。 Composer命令失败: Composer内部增加memorylimit到1.5G. 解决:修改php.ini配置,将memorylimit改的大一些; 报错2:PHP版本问题。. There is a variable APPKEY just like there is in Laravel. Now I tried out the simple command php artisan key: generate to. Php artisan key: generate Edit You may use Lumen Generator. It covers so much commands you are missing from Laravel. For me the easiest way to generate a Lumen key is typing on console one of these commands. Jan 26, 2019 We don’t actually need to create a new.env file. Laravel does the job for us. There exists a.env.example file, rename it as.env. Do this and again generate the key with php artisan key:generate. Keys will be generated successfully. And now try to run php artisan serve. Dec 27, 2019 Problem You want to set a new application key. Solution Use the php artisan key:generate command. Discussion You shouldn’t need to do this. When you first create your Laravel application, key:generate is automatically called. Learn to use PHP Artisan to create custom composer commands in Laravel. Manage various operations by making Laravel Artisan commands easily with this guide. This website uses cookies. Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.
I am building a project using Laravel. It was working fine on localhost, but when I upload it to the server (the server has comodo ssl installed), I receive the following error:
Can anyone help solve this error?
Do you have all the necessary extensions installed on the server?
- PHP >= 5.5.9
- OpenSSL PHP Extension
- PDO PHP Extension
- Mbstring PHP Extension
- Tokenizer PHP Extension
It could be that you’re missing the OpenSSL extension. Also, do you have the key set in .env
file?
Try running:
php artisan key:generate
Answer: the 'cipher' => '
was not set.
Answer:
You only type in console:
And if your app.php not change this Key, change manually.
Next if you should then happen to get this error message:
[ErrorException] file_get_contents(/path/to/my/project/.env): failed to open stream: No such file or directory
Then make a copy of the .env.example
file and try again:
Answer:
I have same issue before and I fixed it follow this way:
Go to config/app.php,
change 'cipher' => 'anything'
to
Answer:
Answer:
I just fix error.
Shift+Click
right mouse to “open commend window here” from your root project.- In console write:
'php artisan key:generate'
. - Get 32 character ‘Mark’ to
config/app.php
like'key' => env('APP_KEY', 'insert get 32 char key')
,//line number 81
Answer:
In root directory, if there is .env.example
file then change it to .env
and then run php artisan key:generate
. This worked for me.
Answer:
In my case, I need to enable mcrypt extension.
But first, check if you already have it:
Check if mcrypt module is loaded:
if nothing shows, is because is not loaded, but you already have installed above right? So do this:
Check again and you should see mcrypt instead of nothing. Thats a good sign, reload you app and go fix your next error 😉
Answer:
write in console php artisan key:generate
you will get message like: Application key [get 32 char key] set successfully.
replace app key in config/app.php
like 'key' => env('APP_KEY', 'insert get 32 char key'),//line number 81
Answer:
Answer:
if you are using app.php configuration file instead of reading key from .env file, then you can remove the env() function on key variable, ex:
to
Answer:
I managed to solve deployment to live Ubuntu server, here is all the steps
Ensure PHP >= 5.5.9
Ensure, OpenSSL, Mbstring, Tokenizer and mcrypt is installed.
To Install mcrypt in PHP (Ubuntu):
Make storage folder writable:
Make Apache use the Lavarel /public folder as home:
Major gotcha for me is FTP might not copy hidden files by default:.env
and /public/.htaccess
need to be there!
After completing the tasks above, it worked on Ubuntu server
Answer:
I was suffering with this problem for a few too many hours before I discovered that the key was being cached in the bootstrapcacheconfig.php. Deleted the file and my site loaded fine (i.e. there was otherwise no problem with my config).
I discovered this by adding some debug output to boostrapcachecompiled.php to make it spit out the cipher and key (somewhere around line 7010). Then dug around to see how it was picking up the config and found it uses a cache config file.
Answer:
Please make sure you have this requirements in your machine.
- PHP >= 5.6.4
- OpenSSL PHP Extension
- PDO PHP Extension
- Mbstring PHP Extension
- Tokenizer PHP Extension
- XML PHP Extension
Then after install or updating your project by
composer update
After this you have–
.env.example
Make a duplicate and rename it to–
.env
and make changes according to your database configuration or any other modifications you need.
Finally generate your application key by–
php artisan key:generate
For Someone may be only last step is enough. But I have this problem every time I clone any laravel project. This whole step makes this with any hazard.
Answer:
Add 'illuminate/html': '~5.0'
to require section of your composer.json
file. Just like this:
Then run composer install
command. When composer install
gets complete. run php artisan key:generate
. You will get a message like this:
Tags: laravel, php, phplaravel
-->Note
This article deploys an app to App Service on Windows. To deploy to App Service on Linux, see Build a PHP and MySQL app in Azure App Service on Linux.
Azure App Service provides a highly scalable, self-patching web hosting service. This tutorial shows how to create a PHP app in Azure and connect it to a MySQL database. When you're finished, you'll have a Laravel app running on Azure App Service.
In this tutorial, you learn how to:
- Create a MySQL database in Azure
- Connect a PHP app to MySQL
- Deploy the app to Azure
- Update the data model and redeploy the app
- Stream diagnostic logs from Azure
- Manage the app in the Azure portal
If you don't have an Azure subscription, create a free account before you begin.
Prerequisites
To complete this tutorial:
- Enable the following PHP extensions Laravel needs: OpenSSL, PDO-MySQL, Mbstring, Tokenizer, XML
Prepare local MySQL
In this step, you create a database in your local MySQL server for your use in this tutorial.
Connect to local MySQL server
In a terminal window, connect to your local MySQL server. You can use this terminal window to run all the commands in this tutorial.
If you're prompted for a password, enter the password for the root
account. If you don't remember your root account password, see MySQL: How to Reset the Root Password.
If your command runs successfully, then your MySQL server is running. If not, make sure that your local MySQL server is started by following the MySQL post-installation steps.
Create a database locally
At the mysql
prompt, create a database.
Exit your server connection by typing quit
.
Create a PHP app locally
In this step, you get a Laravel sample application, configure its database connection, and run it locally.
Clone the sample
In the terminal window, cd
to a working directory.
Run the following command to clone the sample repository.
cd
to your cloned directory.Install the required packages.
Configure MySQL connection
In the repository root, create a text file named .env. Copy the following variables into the .env file. Replace the <root_password> placeholder with the MySQL root user's password.
For information on how Laravel uses the .env file, see Laravel Environment Configuration.
Run the sample locally
Run Laravel database migrations to create the tables the application needs. To see which tables are created in the migrations, look in the database/migrations directory in the Git repository.
Laravel Key Generate
Generate a new Laravel application key. /prince-of-persia-forgotten-sands-cd-key-generator.html.
Run the application.
Navigate to http://localhost:8000
in a browser. Add a few tasks in the page.
To stop the PHP server, type Ctrl + C
in the terminal.
Use Azure Cloud Shell
Azure hosts Azure Cloud Shell, an interactive shell environment that you can use through your browser. You can use either Bash or PowerShell with Cloud Shell to work with Azure services. You can use the Cloud Shell preinstalled commands to run the code in this article without having to install anything on your local environment.
To start Azure Cloud Shell:
Option | Example/Link |
---|---|
Select Try It in the upper-right corner of a code block. Selecting Try It doesn't automatically copy the code to Cloud Shell. | |
Go to https://shell.azure.com, or select the Launch Cloud Shell button to open Cloud Shell in your browser. | |
Select the Cloud Shell button on the menu bar at the upper right in the Azure portal. |
To run the code in this article in Azure Cloud Shell:
Start Cloud Shell.
Select the Copy button on a code block to copy the code.
Paste the code into the Cloud Shell session by selecting Ctrl+Shift+V on Windows and Linux or by selecting Cmd+Shift+V on macOS.
Select Enter to run the code.
Create MySQL in Azure
In this step, you create a MySQL database in Azure Database for MySQL. Later, you configure the PHP application to connect to this database.
Create a resource group
A resource group is a logical container into which Azure resources like web apps, databases, and storage accounts are deployed and managed. For example, you can choose to delete the entire resource group in one simple step later.
In the Cloud Shell, create a resource group with the az group create
command. The following example creates a resource group named myResourceGroup in the West Europe/generate-100s-microsoft-keys-how-china.html. location. To see all supported locations for App Service in Free tier, run the az appservice list-locations --sku FREE
command.
You generally create your resource group and the resources in a region near you.
When the command finishes, a JSON output shows you the resource group properties.
Create a MySQL server
In the Cloud Shell, create a server in Azure Database for MySQL with the az mysql server create
command.
In the following command, substitute a unique server name for the <mysql_server_name> placeholder, a user name for the <admin_user>, and a password for the <admin_password> placeholder. The server name is used as part of your MySQL endpoint (https://<mysql_server_name>.mysql.database.azure.com
), so the name needs to be unique across all servers in Azure.
Note
Since there are several credentials to think about in this tutorial, to avoid confusion, --admin-user
and --admin-password
are set to dummy values. In a production environment, follow security best practices when choosing a good username and password for your MySQL server in Azure.
When the MySQL server is created, the Azure CLI shows information similar to the following example:
Configure server firewall
In the Cloud Shell, create a firewall rule for your MySQL server to allow client connections by using the az mysql server firewall-rule create
command. When both starting IP and end IP are set to 0.0.0.0, the firewall is only opened for other Azure resources.
Tip
You can be even more restrictive in your firewall rule by using only the outbound IP addresses your app uses.
In the Cloud Shell, run the command again to allow access from your local computer by replacing <your_ip_address> with your local IPv4 IP address.
Connect to production MySQL server locally
In the local terminal window, connect to the MySQL server in Azure. Use the value you specified previously for <mysql_server_name>. When prompted for a password, use the password you specified when you created the database in Azure.
Create a production database
At the mysql
prompt, create a database.
Create a user with permissions
Create a database user called phpappuser and give it all privileges in the sampledb
database. Again, for simplicity of the tutorial, use MySQLAzure2017 as the password.
Exit the server connection by typing quit
.
Connect app to Azure MySQL
In this step, you connect the PHP application to the MySQL database you created in Azure Database for MySQL.
Configure the database connection
In the repository root, create an .env.production file and copy the following variables into it. Replace the placeholder <mysql_server_name> in both DB_HOST and DB_USERNAME.
Save the changes.
Tip
To secure your MySQL connection information, this file is already excluded from the Git repository (See .gitignore in the repository root). Later, you learn how to configure environment variables in App Service to connect to your database in Azure Database for MySQL. With environment variables, you don't need the .env file in App Service.
Configure TLS/SSL certificate
By default, Azure Database for MySQL enforces TLS connections from clients. To connect to your MySQL database in Azure, you must use the .pem certificate supplied by Azure Database for MySQL.
Open config/database.php and add the sslmode
and options
parameters to connections.mysql
, as shown in the following code.
The certificate BaltimoreCyberTrustRoot.crt.pem
is provided in the repository for convenience in this tutorial.
Test the application locally
Run Laravel database migrations with .env.production as the environment file to create the tables in your MySQL database in Azure Database for MySQL. Remember that .env.production has the connection information to your MySQL database in Azure.
.env.production doesn't have a valid application key yet. Generate a new one for it in the terminal.
Run the sample application with .env.production as the environment file.
Navigate to http://localhost:8000
. If the page loads without errors, the PHP application is connecting to the MySQL database in Azure.
Add a few tasks in the page.
To stop PHP, type Ctrl + C
in the terminal.
Commit your changes
Run the following Git commands to commit your changes:
Your app is ready to be deployed.
Deploy to Azure
In this step, you deploy the MySQL-connected PHP application to Azure App Service.
Configure a deployment user
FTP and local Git can deploy to an Azure web app by using a deployment user. Once you configure your deployment user, you can use it for all your Azure deployments. Your account-level deployment username and password are different from your Azure subscription credentials.
Free Keygens Downloads
To configure the deployment user, run the az webapp deployment user set command in Azure Cloud Shell. Replace <username> and <password> with a deployment user username and password.
- The username must be unique within Azure, and for local Git pushes, must not contain the ‘@’ symbol.
- The password must be at least eight characters long, with two of the following three elements: letters, numbers, and symbols.
The JSON output shows the password as null
. If you get a 'Conflict'. Details: 409
error, change the username. If you get a 'Bad Request'. Details: 400
error, use a stronger password.
Record your username and password to use to deploy your web apps.
Create an App Service plan
In the Cloud Shell, create an App Service plan with the az appservice plan create
command.
The following example creates an App Service plan named myAppServicePlan
in the Free pricing tier:
When the App Service plan has been created, the Azure CLI shows information similar to the following example:

Create a web app
Create a web app in the myAppServicePlan
App Service plan.
In the Cloud Shell, you can use the az webapp create
command. In the following example, replace <app-name>
with a globally unique app name (valid characters are a-z
, 0-9
, and -
). The runtime is set to PHP 7.3
. To see all supported runtimes, run az webapp list-runtimes --linux
.
When the web app has been created, the Azure CLI shows output similar to the following example:
You’ve created an empty new web app, with git deployment enabled.
Note
The URL of the Git remote is shown in the deploymentLocalGitUrl
property, with the format https://<username>@<app-name>.scm.azurewebsites.net/<app-name>.git
. Save this URL as you need it later.
Configure database settings
As pointed out previously, you can connect to your Azure MySQL database using environment variables in App Service.
In the Cloud Shell, you set environment variables as app settings by using the az webapp config appsettings set
command.
The following command configures the app settings DB_HOST
, DB_DATABASE
, DB_USERNAME
, and DB_PASSWORD
. Replace the placeholders <appname> and <mysql_server_name>.
You can use the PHP getenv method to access the settings. the Laravel code uses an env wrapper over the PHP getenv
. For example, the MySQL configuration in config/database.php looks like the following code:
Configure Laravel environment variables
Laravel needs an application key in App Service. You can configure it with app settings.
In the local terminal window, use php artisan
to generate a new application key without saving it to .env.
In the Cloud Shell, set the application key in the App Service app by using the az webapp config appsettings set
command. Replace the placeholders <appname> and <outputofphpartisankey:generate>.
APP_DEBUG='true'
tells Laravel to return debugging information when the deployed app encounters errors. When running a production application, set it to false
, which is more secure.
Set the virtual application path
Set the virtual application path for the app. This step is required because the Laravel application lifecycle begins in the public directory instead of the application's root directory. Other PHP frameworks whose lifecycle start in the root directory can work without manual configuration of the virtual application path.
In the Cloud Shell, set the virtual application path by using the az resource update
command. Replace the <appname> placeholder.
By default, Azure App Service points the root virtual application path (/) to the root directory of the deployed application files (siteswwwroot).
Push to Azure from Git
Back in the local terminal window, add an Azure remote to your local Git repository. Replace <deploymentLocalGitUrl-from-create-step> with the URL of the Git remote that you saved from Create a web app.
Push to the Azure remote to deploy your app with the following command. When Git Credential Manager prompts you for credentials, make sure you enter the credentials you created in Configure a deployment user, not the credentials you use to sign in to the Azure portal.
This command may take a few minutes to run. While running, it displays information similar to the following example:
Note
You may notice that the deployment process installs Composer packages at the end. App Service does not run these automations during default deployment, so this sample repository has three additional files in its root directory to enable it:
.deployment
- This file tells App Service to runbash deploy.sh
as the custom deployment script.deploy.sh
- The custom deployment script. If you review the file, you will see that it runsphp composer.phar install
afternpm install
.composer.phar
- The Composer package manager.
You can use this approach to add any step to your Git-based deployment to App Service. For more information, see Custom Deployment Script.
Browse to the Azure app
Browse to http://<app_name>.azurewebsites.net
and add a few tasks to the list.
Congratulations, you're running at see console logs immediately, check again in 30 seconds.
To stop log streaming at anytime, type Ctrl
+C
.
Tip
A PHP application can use the standard error_log() to output to the console. The sample application uses this approach in app/Http/routes.php.
As a web framework, Laravel uses Monolog as the logging provider. To see how to get Monolog to output messages to the console, see PHP: How to use monolog to log to console (php://out).
Manage the Azure app
Go to the Azure portal to manage the app you created.
From the left menu, click App Services, and then click the name of your Azure app.
You see your app's Overview page. Here, you can perform basic management tasks like stop, start, restart, browse, and delete.
Laravel Generator
The left menu provides pages for configuring your app.
Clean up resources
In the preceding steps, you created Azure resources in a resource group. If you don't expect to need these resources in the future, delete the resource group by running the following command in the Cloud Shell:
This command may take a minute to run.
Next steps
In this tutorial, you learned how to:
- Create a MySQL database in Azure
- Connect a PHP app to MySQL
- Deploy the app to Azure
- Update the data model and redeploy the app
- Stream diagnostic logs from Azure
- Manage the app in the Azure portal
Laravel Php Download
Advance to the next tutorial to learn how to map a custom DNS name to the app.