Laravel is a framework built in PHP. It is an open-source programming language that has been at the forefront of the most popular backend languages for many years. Laravel itself has many features and tools that make programming efficient and trouble-free.
Laravel follows the model-view-controller design pattern (MVC). Laravel reuses existing components of various frameworks. This is useful to build web applications. Web applications designed in this way are more structured and practical.
Laravel provides a powerful file system abstraction with the Flysystem
PHP package. Laravel Flysystem
integration provides a simple driver for working with local file systems,
Laravel’s file system configuration files are located in config / filesystems.php
. This file allows you to configure the disks of any file system. Each disk represents a specific storage driver and location.
The local driver interacts with files stored locally on the server running the Laravel application while the S3 driver is used to write to Amazon’s S3 cloud storage service.
By default, public disks use local drivers and store these files under storage/app/public
. To access them via the web, you need to create a symbolic link from public/storage
to storage/app/public
.
.env file
, create a variable called FILESYSTEM_DRIVER
, and set it to public
, as shown below:FILESYSTEM_DRIVER=public
Next, use the command below in order to create the symbolic link.
php artisan storage:link
Artisan :: call()
method on the route or controller to execute Artisan
commands without using a terminal.
First, go to the route folder your-app-folder/routes/web.php
and register a new route as follows.Route::get('/linkstorage', function () {
Artisan::call('storage:link');
});
Then, when you go to your website, you get a blank page. A storage folder is created.
public
directory and run:rm storage
Then go to the project root and run:
php artisan storage:link
config/file
systems from:'local' => [
'driver' => 'local',
'root' => storage_path('app'),
]
to:
'local' => [
'driver' => 'local',
'root' => storage_path('app/public'),
]