How to use the command 'laravel new' (with examples)

How to use the command 'laravel new' (with examples)

The laravel new command is a command-line installer for the Laravel framework. It allows users to quickly create a new Laravel application with various options and features.

Use case 1: Create a new Laravel application

Code:

laravel new name

Motivation: This use case is used to create a new Laravel application with the given name. It is useful when starting a new Laravel project.

Explanation: The command laravel new is followed by the desired name for the new Laravel application. The name is the name that will be given to the new Laravel application directory.

Example output:

Crafting application...
Application ready! Build something amazing.

Use case 2: Use the latest development release

Code:

laravel new name --dev

Motivation: This use case is used to create a new Laravel application using the latest development release. It is useful for testing new features and changes in the Laravel framework.

Explanation: The command laravel new is followed by the desired name for the new Laravel application. The --dev option specifies that the latest development release should be used.

Example output:

Crafting application...
Application ready! Build something amazing.

Use case 3: Overwrite if the directory already exists

Code:

laravel new name --force

Motivation: This use case is used to create a new Laravel application, even if the directory with the same name already exists. It is useful when you want to re-create the Laravel application with the same name.

Explanation: The command laravel new is followed by the desired name for the new Laravel application. The --force option specifies that the command should overwrite the existing directory if it already exists.

Example output:

Crafting application...
Application ready! Build something amazing.

Use case 4: Install the Laravel Jetstream scaffolding

Code:

laravel new name --jet

Motivation: This use case is used to install the Laravel Jetstream scaffolding in the new Laravel application. Laravel Jetstream provides a starting point for new Laravel applications with login, registration, and two-factor authentication features.

Explanation: The command laravel new is followed by the desired name for the new Laravel application. The --jet option specifies that the Laravel Jetstream scaffolding should be installed.

Example output:

Crafting application...
Installing Laravel Jetstream...
Application ready! Build something amazing.

Use case 5: Install the Laravel Jetstream scaffolding with a specific stack

Code:

laravel new name --jet --stack livewire|inertia

Motivation: This use case is used to install the Laravel Jetstream scaffolding with a specific stack, either Livewire or Inertia. Laravel Jetstream supports both Livewire and Inertia as the front-end stack.

Explanation: The command laravel new is followed by the desired name for the new Laravel application. The --jet option specifies that the Laravel Jetstream scaffolding should be installed. The --stack option specifies the desired front-end stack and can be either livewire or inertia.

Example output:

Crafting application...
Installing Laravel Jetstream (Livewire)...
Application ready! Build something amazing.

Use case 6: Install the Laravel Jetstream scaffolding with support for teams

Code:

laravel new name --jet --teams

Motivation: This use case is used to install the Laravel Jetstream scaffolding with support for teams. Laravel Jetstream provides built-in support for teams, allowing users to collaborate on projects.

Explanation: The command laravel new is followed by the desired name for the new Laravel application. The --jet option specifies that the Laravel Jetstream scaffolding should be installed. The --teams option enables support for teams in the application.

Example output:

Crafting application...
Installing Laravel Jetstream (with Teams)...
Application ready! Build something amazing.

Use case 7: List the available installer commands

Code:

laravel list

Motivation: This use case is used to list all the available installer commands for Laravel.

Explanation: The command laravel list is used to display a list of all the available installer commands for Laravel.

Example output:

Available commands:
  new              Create a new Laravel application
  help             Displays help for a command
  list             Lists commands
  migrate          Run the database migrations
  serve            Serve the application on the PHP development server
  ...

Conclusion:

The laravel new command is a versatile command-line installer for the Laravel framework. It provides various options and features to easily create a new Laravel application, install Laravel Jetstream scaffolding, and more. With these examples, users can get started with Laravel development quickly and efficiently.

Related Posts

How to use the command gnmic (with examples)

How to use the command gnmic (with examples)

The gnmic command is a gNMI (gRPC Network Management Interface) command-line client that allows users to manage gNMI network device configuration and view operational data.

Read More
How to use the command `cotton` (with examples)

How to use the command `cotton` (with examples)

cotton is a Markdown test specification runner. It allows you to run tests written in Markdown format and provides various options for customization.

Read More
How to use the command ppmshadow (with examples)

How to use the command ppmshadow (with examples)

The ppmshadow command is used to add simulated shadows to a PPM image.

Read More