onix-systems-php / hyperf-file-upload
An extension to maintain file upload and assignation
Installs: 2 414
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 1
Open Issues: 0
Type:extension
Requires
- php: >=8.1
- ext-fileinfo: *
- ext-gd: *
- ext-json: *
- hyperf/config: ^3.1
- hyperf/contract: ^3.1
- hyperf/database: ^3.1
- hyperf/db-connection: ^3.1
- hyperf/filesystem: ^3.1
- hyperf/guzzle: ^3.1
- hyperf/translation: ^3.1
- hyperf/validation: ^3.1
- intervention/image: ^3.0
- league/flysystem: ^2.0|^3.0
- onix-systems-php/hyperf-actions-log: ^1.2
- onix-systems-php/hyperf-core: >=1.2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- mockery/mockery: ^1.0
- phpstan/phpstan: ^1.0
- phpunit/phpunit: >=7.0
- swoole/ide-helper: ^4.5|^5.0
Suggests
- swow/swow: Required to create swow components.
README
Includes the following classes:
- Model:
- File;
- FileRelations trait.
- Repository:
- FileRepository.
- Service:
- AddExternalFileService;
- AddFileService;
- ClearUnusedDeletedFilesService;
- DownloadFileService.
Install:
composer require onix-systems-php/hyperf-file-upload
Publish config and database migrations:
php bin/hyperf.php vendor:publish onix-systems-php/hyperf-file-upload
Fill file_upload
config with file upload configuration, following existing examples.
Add $fileRelations
config and FileRelations
trait to models you want assign files to:
use FileRelations; public $fileRelations = [ 'avatar' => [ 'limit' => 1, 'required' => false, 'mimeTypes' => [image/png', 'image/jpg', 'image/jpeg', 'image/bmp'], 'presets' => [ '150x150' => ['fit' => [150, 150]], '250x250' => ['fit' => [250, 250]], ], ], 'documents' => [ 'limit' => null, 'required' => false, 'mimeTypes' => ['application/pdf'], ], ];
Methods you might need to redefine in FileRelations
trait:
getAuth
: this method should return active userprocessFileActions
: if you defined new extra actions in config, you'll need to define action's login in this method