Today, I will test the use of sftp driver on Laravel. If you have never used it, come and see the results of my test.
By the way, it is very convenient for us to perform the Storage function in the tinker environment of Laravel. , whether local or remote.
After adjusting the settings, remember to exit and enter again.
The Laravel version used in this article is as follows:
dlaravel@4e1f08f98079:~/html$ artisan -V
Laravel Framework 9.40.1
Laravel's Storage sftp driver support can be installed
composer require league/flysystem-sftp-v3 "^3.0"
Then we can add the required driver in config/filesystems.php, here I added a ccc SFTP driver
'disks' => [
'ccc' => [
'driver' => 'sftp',
'host' => '192.168.99.2',
'username' => 'dlaravel',
'privateKey' => '/home/dlaravel/.ssh/id_ed25519',
'port' => 2258,
'root' => '/var/www/html/storage/app/public',
'url'=>'https://www.ccc.tc/storage',
],
],
Here, we can customize the root as public
/var/www/html is my Laravel project directory.
In this way, when we want to capture the files in the public directory, we can directly give the images directory.
The root is adjusted according to the needs of the time. In my case, it is quite convenient to set the root to public.
In ccc disk In the SFTP driver, I also set the url, so when we use Storage::url,
bring in the files listed in Storage::disk("ccc")→files, the remote end can be captured very smoothly URL of the image file
Remarks, regarding the public folder in storage/app, it should be open to external access, remember to issue a command to create a soft link.
php artisan storage:link
No Comment
Post your comment