ekino/tiny-png-sonata-media-bundle
Composer 安装命令:
composer require ekino/tiny-png-sonata-media-bundle
包简介
Tiny Png integration with SonataMedia by Ekino
README 文档
README
This is a work in progress, so if you'd like something implemented please feel free to ask for it or contribute to help us!
Resources
Purpose
Automatize image optimization through tinyPNG service. You can only use the client or get the full process with sonata media and sonata notification.
Installation
Step 1: add dependency
$ composer require ekino/tiny-png-sonata-media-bundle
Step 2: register the bundle
Symfony 2 or 3:
<?php // app/AppKernel.php public function registerBundles() { $bundles = [ // ... new Ekino\TinyPngSonataMediaBundle\EkinoTinyPngSonataMediaBundle(), // ... ]; }
Symfony 4:
<?php // config/bundles.php return [ // ... Ekino\TinyPngSonataMediaBundle\EkinoTinyPngSonataMediaBundle::class => ['all' => true], // ... ];
Step 3: configure the bundle
ekino_tiny_png_sonata_media: tiny_png_api_key: ~ # required providers: [] # default max_compression_count_by_month: 500 # default value defined in config
Step 4: define the sonata notification queue for asynchronous behaviour
Usage
Use the tinyPng client
Client can be used directly to optimize images through tinyPNG API. However, image optimization should not be done synchronously as it takes time.
If you know what you are doing, you can use the ekino.tiny_png_sonata_media.tinify.client and its optimize method:
<?php $client->optimize($inputPath, $outputPath, $overwrite);
Full process with sonata media & notification
This bundle listen doctrine events (postPersist & postUpdate) on media entity. As soon as the media's provider is in
the whitelist (defined in configuration), it will publish a sonata notification message
(type: ekino.tiny_png_sonata_media.optimize_image) to be handled by a consumer
(Ekino\TinyPngSonataMediaBundle\Consumer\OptimizeImageConsumer). This consumer will contact tinyPNG API for
optimization, replace it on the server and update media size in database.
Suggest install LiipMonitorBundle
This bundle provides a service using liip/monitor-bundle to check the count of compressions made this month.
Note
- Only Sonata\MediaBundle\Filesystem\Local adapter is supported for now.
- Only png, jpg & jpeg files extensions are handled by this bundle as the tinyPNG only handle those ones.
- Regeneration of thumbnails after optimization is not yet supported.
ekino/tiny-png-sonata-media-bundle 适用场景与选型建议
ekino/tiny-png-sonata-media-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 460 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 07 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「media」 「sonata」 「tiny png」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ekino/tiny-png-sonata-media-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ekino/tiny-png-sonata-media-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ekino/tiny-png-sonata-media-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Sonata Extra admin features
ACL list filtering for SonataAdmin
Simple Sharing generates social media share links within CP entry pages, allowing you to quickly & easily share entries.
A Statamic fieldtype for TinyMCE using Tiny Cloud for Statamic 6.
This bundle track command execution in the database.
统计信息
- 总下载量: 460
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-07-31