iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🌿

Laravel 11 install Commands

に公開
2024/12/16

This article is for Day 12 of the Advent Calendar 2024: Investigating all Artisan commands in Laravel 11.

This time, I investigated the install command.

Environment

  • PHP 8.4.1
  • laravel/laravel 11.3.3
  • laravel/framework 11.33.2

install:api

Creates the API route file and installs Laravel Sanctum or Laravel Passport.

php artisan install:api

Running this command creates the API route file (routes/api.php) by copying the stub file below:
https://github.com/laravel/framework/blob/v11.33.2/src/Illuminate/Foundation/Console/stubs/api-routes.stub

Additionally, it installs Laravel Sanctum (laravel/sanctum).
Finally, it runs the migration for the table used by Laravel Sanctum (personal_access_tokens). (You will be prompted to confirm whether to run it or not.)

Option Description
--composer[=COMPOSER] Specify the path to the Composer binary
--force Overwrite the existing API route file
--passport Install Laravel Passport
--without-migration-prompt Do not run migrations
  • You can specify the path to the Composer binary with --composer (default is global).
  • Adding --force will overwrite the existing API route file (routes/api.php) with the contents of the stub.
  • Adding --passport will install Laravel Passport (laravel/passport) instead of Laravel Sanctum.
  • Adding --without-migration-prompt will end the command without running the migration for the table used by Laravel Sanctum.

install:broadcasting

Enables the broadcasting feature.

php artisan install:broadcasting

Running this command creates the channel route file (routes/channels.php) by copying the stub file below:
https://github.com/laravel/framework/blob/v11.33.2/src/Illuminate/Foundation/Console/stubs/broadcasting-routes.stub

A configuration file (config/broadcasting.php) is also created at the same time.

Additionally, it installs Laravel Reverb (laravel/reverb). (You will be prompted to confirm whether to install it or not.)
Finally, it installs Node dependency packages (laravel-echo, pusher-js). (You will be prompted to confirm whether to install them or not.)

Option Description
--composer[=COMPOSER] Specify the path to the Composer binary
--force Overwrite the existing channel route file
--without-reverb Do not install Laravel Reverb
--without-node Do not install Node dependency packages
  • You can specify the path to the Composer binary with --composer (default is global).
  • Adding --force will overwrite the existing channel route file (routes/channels.php) with the contents of the stub.
  • Adding --without-reverb will skip the installation of Laravel Reverb.
  • Adding --without-node will skip the installation of Node dependency packages.
GitHubで編集を提案

Discussion