Laravel is an excellent PHP framework, which is widely used in web application development, API development and other fields. The installation of Laravel is very simple. Let's introduce the installation tutorial of Laravel system.
1. Environmental requirements
Before starting the installation of Laravel, we need to ensure that our computer meets the following environmental requirements:
2. Laravel installation process
Laravel is based on Composer. So we need to install Composer before starting. Just download the installation package for the corresponding operating system from the official website.
Next we need to create a Laravel project through Composer. Open the command terminal and enter the directory where you will create the Laravel project, and execute the following command:
composer create-project --prefer-dist laravel/laravel 项目名称
Theproject name
here can be customized. This command will download the latest stable version from the Laravel official warehouse Laravel and install it into theproject name
folder.
After the download is completed, open the.env
file and configure it accordingly according to your database configuration information. The default database driver in the configuration file ismysql
. If you want to use other database types, you need to make the corresponding configuration in theconfig/database.php
file.
In Laravel’s.env
file, there is a configuration item namedAPP_KEY
, which is used to encrypt the data required by the application. If you plan to use an encryption scheme with Laravel, you will need to generate an application key within your application. Open the command terminal and enter the following command in the project root directory:
php artisan key:generate
If the execution is successful, you can see a newAPP_KEY# in your
.envfile ## Configuration items.
php artisan serve
composer create-projectcommand:
[ErrorException] file_put_contents(C:UsersUserNameAppDataRoamingComposerendorlaravel ramework.gitattributes): failed to open stream: Permission denied
composer create-project --prefer-dist --no-scripts --no-progress laravel/laravel 项目名称
--no-scriptsparameter in this command means to skip executing the Composer script when creating the project. And
--no-progressis used to turn off the progress bar.
composer updatecommand. This is caused by Laravel not loading the class. You can reload Composer autoload files using the following command:
composer dump-autoload
404 Not Foundoccurs when you access the application The error may be caused by you not setting the correct database information in the
.envfile. Please make sure you have set the correct database information in the configuration file.
No supported encrypter found. The cipher and / or key length are invalid.
. This is caused by theAPP_KEY
value in the envfile being empty or invalid. You need to use the command
php artisan key:generateto generate a key for encryption. If you have already generated a key, please check whether the value of this configuration item in your
.envfile is correct.
The above is the detailed content of laravel system installation tutorial. For more information, please follow other related articles on the PHP Chinese website!