Code to create a new laravel project with composer
To create a new Laravel project using Composer, you can follow these steps:
Step 1: Install Composer
If you haven't already, download and install Composer from the official website: https://getcomposer.org/download/
Step 2: Create a new project directory
Create a new directory for your project, for example: my-laravel-project
Step 3: Initialize the project with Composer
Open a terminal or command prompt and navigate to the project directory:
cd my-laravel-project
Then, run the following command to initialize the project with Composer:
composer create-project --prefer-dist laravel/laravel.
This command tells Composer to create a new Laravel project in the current directory (.
) using the laravel/laravel
package.
Step 4: Wait for the installation to complete
Composer will download and install the required dependencies, including Laravel and its dependencies. This may take a few minutes, depending on your internet connection and the speed of your computer.
Step 5: Set up the project
Once the installation is complete, you'll see a message indicating that the project has been created successfully. You can now set up your project by running the following command:
php artisan key:generate
This command generates a random encryption key for your project.
Step 6: Start the development server
To start the development server, run the following command:
php artisan serve
This command starts the development server, which you can access by navigating to http://localhost:8000
in your web browser.
That's it! You now have a brand new Laravel project set up and ready to go.
Note: If you want to specify a different project name or directory, you can modify the composer create-project
command accordingly. For example:
composer create-project --prefer-dist laravel/laravel my-new-project /path/to/my/new/project
This command creates a new Laravel project named my-new-project
in the /path/to/my/new/project
directory.