consilience / laravel-storage-ls
列出Laravel文件系统的内容。
2.2.0
2023-09-21 13:44 UTC
Requires
- php: ^8.0
- illuminate/support: ^9.0|^10.0
README
通过简单的 artisan 命令列出 Laravel 文件系统(即磁盘)的文件。
Laravel 使用 flysystem 包 及其适配器抽象了本地和远程文件系统。Laravel 或 Lumen 中的抽象文件系统单元是 磁盘,每个 磁盘 都在 config/filesystems.php
中配置。此包提供了一个 artisan 命令(storage:ls
),可以快速简单地查看磁盘中的文件和目录。
该命令是只读的,因此不允许添加、删除或修改文件或目录。任何异常都故意未处理,以便有助于诊断连接问题。不需要交互,因此该命令可用于自动化管道,也可以用于允许运行 artisan 命令但提供无交互式外壳的环境,如 vapor。
用法
列出存储磁盘
$ php artisan storage:ls
这将返回带有默认标记 [*] 的可用磁盘列表
Available disks:
+-----------+--------+
| name | driver |
+-----------+--------+
| local [*] | local |
| public | local |
| s3 | s3 |
+-----------+--------+
列出给定磁盘中的文件/目录
$ php artisan storage:ls --disk=s3 # or $ php artisan storage:ls -d s3 # or $ php artisan storage:ls s3:
# Short format $ php artisan storage:ls -d local .gitignore public # Long format (directory flag, size bytes, date/time UTC, file or directory name) $ php artisan storage:ls -d local -l - 14 2019-03-05 14:27:03 .gitignore d 0 2019-08-21 11:19:46 public
列出给定目录中的文件和目录
$ php artisan storage:ls -d s3 my-folder/sub-folder // or separate the disk and directory with a colon $ php artisan storage:ls s3:my-folder/sub-folder
递归列出文件和目录
$ php artisan storage:ls -d local -R
/:
.gitignore
public
/public:
dirA
dirB
xyzFile
public/dirA:
public/dirB:
foobarFile
类似地,在长格式中
$ php artisan storage:ls -d local -Rl
/:
- 14 2019-03-05 14:27:03 .gitignore
d 0 2019-08-21 22:16:46 public
/public:
d 0 2019-08-21 22:16:43 dirB
d 0 2019-08-21 22:17:08 dirB
- 6 2019-08-21 21:54:54 xyzFile
public/dirA:
public/dirB:
- 5 2019-08-21 22:17:08 foobarFile
安装
Laravel 和 Lumen
composer require consilience/laravel-storage-ls
在 Laravel 中无需进行其他配置。
Lumen
由于 Lumen 不对服务提供者进行发现,因此需要手动在 bootstrap/app.php
中注册提供者。
$app->register(Consilience\Laravel\Ls\Providers\LsProvider::class);