iTranslated by AI
Laravel 11 Storage Commands
This article is for Day 23 of the Exploring All Artisan Commands in Laravel 11 Advent Calendar 2024.
This time, I looked into the storage commands.
Environment
- PHP 8.4.1
- laravel/laravel 11.3.3
- laravel/framework 11.33.2
storage:link
Create the symbolic links configured for the application.
php artisan storage:link
When executed, it creates the symbolic links configured for the application.
By default, it creates a symbolic link from storage/app/public to public/storage.
advent-calendar-2024 % php artisan storage:link
INFO The [public/storage] link has been connected to [storage/app/public].
Configuration can be written in the following array in config/filesystems.php.
By adding values to the array, you can increase the number of symbolic links that are created.
'links' => [
public_path('storage') => storage_path('app/public'),
public_path('images') => storage_path('app/images'), // Addition
],
advent-calendar-2024 % php artisan storage:link
INFO The [public/storage] link has been connected to [storage/app/public].
INFO The [public/images] link has been connected to [storage/app/images].
| Option | Description |
|---|---|
--relative |
Create the symbolic links using relative paths |
--force |
Recreate existing symbolic links |
- Adding
--relativewill create the symbolic links using relative paths.
However, to use this option, the symfony/filesystem package must be installed. - Adding
--forcewill delete any existing symbolic links and recreate them.
storage:unlink
Delete the existing symbolic links configured for the application.
php artisan storage:unlink
When executed, it deletes the existing symbolic links.
The targets for deletion are the keys defined in the array in config/filesystems.php.
In the following case, public_path('storage') and public_path('images') are the targets for deletion:
'links' => [
public_path('storage') => storage_path('app/public'),
public_path('images') => storage_path('app/images'),
],
Discussion