tobento/app-file-storage
最新稳定版本:2.0
Composer 安装命令:
composer require tobento/app-file-storage
包简介
App file storage support.
README 文档
README
File storage support for the app.
Table of Contents
Getting Started
Add the latest version of the app file storage project running this command.
composer require tobento/app-file-storage
Requirements
- PHP 8.4 or greater
Documentation
App
Check out the App Skeleton if you are using the skeleton.
You may also check out the App to learn more about the app in general.
File Storage Boot
The file storage boot does the following:
- installs and loads file storage config file
- creates file storages based on storage config file
use Tobento\App\AppFactory; // Create the app $app = new AppFactory()->createApp(); // Add directories: $app->dirs() ->dir(realpath(__DIR__.'/../'), 'root') ->dir(realpath(__DIR__.'/../app/'), 'app') ->dir($app->dir('app').'config', 'config', group: 'config') ->dir($app->dir('root').'public', 'public') ->dir($app->dir('root').'vendor', 'vendor'); // Adding boots: $app->boot(\Tobento\App\FileStorage\Boot\FileStorage::class); // Run the app: $app->run();
You may check out the File Storage Service to learn more about it.
File Storage Config
The configuration for the file storage is located in the app/config/file_storage.php file at the default App Skeleton config location where you can specify the pools and caches for your application.
File Storage Usage
You can access the file storage(s) in several ways:
Using the app
use Tobento\App\AppFactory; use Tobento\Service\FileStorage\StoragesInterface; use Tobento\Service\FileStorage\StorageInterface; $app = new AppFactory()->createApp(); // Add directories: $app->dirs() ->dir(realpath(__DIR__.'/../'), 'root') ->dir(realpath(__DIR__.'/../app/'), 'app') ->dir($app->dir('app').'config', 'config', group: 'config') ->dir($app->dir('root').'public', 'public') ->dir($app->dir('root').'vendor', 'vendor'); // Adding boots: $app->boot(\Tobento\App\FileStorage\Boot\FileStorage::class); $app->booting(); $storages = $app->get(StoragesInterface::class); $defaultStorage = $app->get(StorageInterface::class); // Run the app: $app->run();
You may check out the File Storage Service to learn more about in general.
Check out the Storages Interface to learn more about storages.
Check out the Storage Interface to learn more about the storage.
Using autowiring
You can also request the interfaces in any class resolved by the app:
use Tobento\Service\FileStorage\StoragesInterface; use Tobento\Service\FileStorage\StorageInterface; class SomeService { public function __construct( protected StoragesInterface $storages, protected StorageInterface $storage, ) {} }
Credits
统计信息
- 总下载量: 93
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-06-30