Laravel new
The laravel new
command!
laravel new
is a command-line tool provided by Laravel that allows you to create a new Laravel project from scratch. Here's a breakdown of the command and its options:
Basic Usage:
composer global require laravel/installer
laravel new project-name
Replace project-name
with the desired name for your new Laravel project.
Options:
--composer
: Specify a custom Composer configuration file.--directory
: Specify a custom directory for the project.--force
: Overwrite any existing files or directories.--prefer-dist
: Download the package in a compressed state instead of decompressing it.--dev
: Install the project in development mode.
Example:
composer global require laravel/installer
laravel new my-laravel-project --directory=/path/to/project --force
This command will create a new Laravel project named my-laravel-project
in the specified directory /path/to/project
, overwriting any existing files or directories.
What happens when you run laravel new
?
When you run laravel new
, the following steps occur:
- The Laravel installer checks if you have Composer installed and sets up the project structure.
- It creates a new directory for the project and initializes the project with the Laravel framework.
- It installs the required dependencies using Composer.
- It sets up the project configuration files, such as
composer.json
,webpack.mix.js
, androutes/web.php
. - It creates the basic project structure, including directories for controllers, models, views, and more.
After running laravel new
, you'll have a brand new Laravel project ready to start building your application!