rezozero / intervention-request-bundle
Symfony 扩展包,用于使用 ambroisemaupate/intervention-request 库
3.0.0
2023-02-10 14:14 UTC
Requires
- php: >=8.0
- ambroisemaupate/intervention-request: ^4.0 || dev-develop
- symfony/console: >=4.4.0
- symfony/framework-bundle: >=4.4.0
Requires (Dev)
- phpstan/phpstan: ^1.9.17
- squizlabs/php_codesniffer: ^3.7
This package is auto-updated.
Last update: 2024-09-10 17:28:16 UTC
README
步骤 1:下载扩展包
打开命令行,进入项目目录,并执行以下命令以下载此扩展包的最新稳定版本
$ composer require rezozero/intervention-request-bundle
此命令要求您全局安装 Composer,请参考 Composer 文档中的安装章节。
步骤 2:启用扩展包
然后,通过将其添加到项目 config/bundles.php
文件中注册的扩展包列表来启用扩展包
// config/bundles.php return [ // ... \RZ\InterventionRequestBundle\RZInterventionRequestBundle::class => ['all' => true], ];
添加路由
# app/config/routing.yml # ... rz_intervention_request: resource: "@RZInterventionRequestBundle/Resources/config/routing.yml" prefix: /
步骤 3:配置
# config/packages/rz_intervention_request.yaml parameters: env(IR_DEFAULT_QUALITY): '90' env(IR_MAX_PIXEL_SIZE): '1920' ir_default_quality: '%env(int:IR_DEFAULT_QUALITY)%' ir_max_pixel_size: '%env(int:IR_MAX_PIXEL_SIZE)%' rz_intervention_request: driver: 'gd' default_quality: '%ir_default_quality%' max_pixel_size: '%ir_max_pixel_size%' cache_path: "%kernel.project_dir%/public/assets" files_path: "%kernel.project_dir%/public/files" jpegoptim_path: /usr/bin/jpegoptim pngquant_path: /usr/bin/pngquant subscribers: []
然后在项目的 .env
文件中添加以下变量
###> rezozero/intervention-request-bundle ### IR_DEFAULT_QUALITY=90 IR_MAX_PIXEL_SIZE=2500 ###< rezozero/intervention-request-bundle ###
使用 Flysystem 文件解析器
声明一个名为 intervention_request.storage
的 flysystem 存储,此扩展包将自动使用它而不是 LocalFileResolver
# Read the documentation at https://github.com/thephpleague/flysystem-bundle/blob/master/docs/1-getting-started.md flysystem: storages: intervention_request.storage: adapter: 'local' options: directory: '%kernel.project_dir%/public/files'