Home > Article > PHP Framework > How to install Laravel using the command line
Laravel is a very popular PHP framework, and its elegance and simplicity make it the first choice for developers. However, many developers may not know that Laravel can also be installed via the command line.
In this article, we will learn how to install Laravel using the command line.
Step one: Prepare the environment
Before installation, you must ensure that the following conditions are met:
Step 2: Download Laravel
Laravel can be installed through Composer . Composer is a PHP package manager, and Laravel relies on Composer to manage its dependencies.
First, open your command line tool (Git Bash) and go to the directory where you want to install Laravel. Then run the following command:
composer create-project laravel/laravel
This will download the Laravel framework and all required dependencies and install it in your directory.
Step Three: Create Laravel Project
In the previous step, we have downloaded the Laravel framework. Now, we need to create a new Laravel project. We can do it with the following command:
php artisan new myproject
This will create a new Laravel project named "myproject". You can replace it with any name of your choice.
Step 4: Start the development server
Now that we have created the Laravel project, we need to start the development server so that it can be accessed in the browser. To start the server, use the following command:
cd myproject php artisan serve
This will start the default development server, which will listen on http://localhost:8000. You can visit this URL in your browser to view your new Laravel project.
Step 5: Learn more commands
The Laravel framework provides many commands to simplify the development process. You can simply type "php artisan" and press Enter to see the available commands.
For example, you can create a controller using the following command:
php artisan make:controller MyController
This will create a new controller named "MyController" for use in your application.
Summary
In this article, we discussed how to install and create a new Laravel project using command line tools. By using the command line, you can make the development process faster and more efficient. Hope this article helps you!
The above is the detailed content of How to install Laravel using the command line. For more information, please follow other related articles on the PHP Chinese website!