LinuxCommandLibrary

laravel

Manage and create Laravel projects

TLDR

Create a new Laravel application

$ laravel new [name]
copy

Use the latest development release
$ laravel new [name] --dev
copy

Overwrite if the directory already exists
$ laravel new [name] --force
copy

Install the Laravel Jetstream scaffolding
$ laravel new [name] --jet
copy

Install the Laravel Jetstream scaffolding with a specific stack
$ laravel new [name] --jet --stack [livewire|inertia]
copy

Install the Laravel Jetstream scaffolding with support for teams
$ laravel new [name] --jet --teams
copy

List the available installer commands
$ laravel list
copy

SYNOPSIS

laravel new <project-name> [--git] [--branch] [--dev] [--force] [--jet]

PARAMETERS

new
    The primary subcommand to create a new Laravel application.

<project-name>
    The name of the directory where the new Laravel application will be created. This is a required argument.

--git
    Initialize a Git repository after creating the project.

--branch=
    Specify a particular branch of the Laravel framework to install.

--dev
    Install the development version of the Laravel framework.

--force
    Force the creation of the project even if the directory already exists.
Use with caution!

--jet
    Install Laravel Jetstream with a specific stack (e.g., Livewire, Inertia).
Requires an additional argument for the stack and optionally --teams.

DESCRIPTION

The laravel command on Linux primarily refers to the global Laravel installer, a command-line tool used to quickly scaffold new Laravel projects. It streamlines the initial setup process, downloading the necessary framework files and dependencies. Once a Laravel project is created using this installer, the main command-line utility for interacting with the framework shifts to Artisan, which is invoked via php artisan from within the project directory. Artisan provides a rich set of commands for various development tasks, including database migrations, code generation, testing, and server management. The laravel command itself is a convenient wrapper for getting a new project up and running without manually running Composer create-project commands.

CAVEATS

The laravel command requires PHP and Composer to be installed and configured on your system. It's typically installed globally via Composer (composer global require laravel/installer).
This command is primarily for *creating* new projects; for daily development tasks within a Laravel project, the php artisan command is used.

ARTISAN COMMAND-LINE INTERFACE

Once a Laravel project is created using the laravel new command, most command-line interactions happen through Artisan, Laravel's built-in CLI tool. Artisan is invoked using php artisan from within the project's root directory. It offers hundreds of commands for tasks like running migrations (php artisan migrate), creating controllers/models (php artisan make:controller), serving the application locally (php artisan serve), and managing queues (php artisan queue:work).

INSTALLATION

The laravel command is not part of a standard Linux distribution. To use it, you must first install PHP and Composer, then execute:
composer global require laravel/installer
Ensure your Composer global binaries directory is in your system's PATH environment variable.

HISTORY

Laravel, created by Taylor Otwell, first released in 2011, quickly gained popularity for its elegant syntax and developer-friendly features. The global laravel installer was introduced to simplify the process of setting up new projects, abstracting away the underlying Composer commands. This made onboarding new developers and quickly spinning up new applications much easier, contributing to Laravel's widespread adoption as one of the leading PHP frameworks.

SEE ALSO

php(1), composer(1)

Copied to clipboard