truesocialmetrics/cdn
Composer 安装命令:
composer require truesocialmetrics/cdn
包简介
Cdn helper for ZF2/ZF3/Laminas
README 文档
README
Version 2.* Created by Rostislav Mykhajliw
Introduction
TweeCdn is a list of view helpers for support css/js/images links transformation due to rules.
Requirements
- php >= 7
- zendframework/zend-stdlib
- zendframework/zend-view
Features / Goals
- Simple by adding ?timestamp marker to the end of file e.q. /css/test.css?1234567
- Release idenitify new static files version by given REVISION number e.q. /css/1234/test.css
- Hash build unique marker based on file md5 hash e.q. /css/af34c42/test.css. It allows users to load only changed files.
- Multiple hostnames supports e.q. host1.com, host2.com
- Hash generator
Installation
Main Setup
With composer
-
Add this project and Cdn in your composer.json:
"require": { "necromant2005/cdn": "*", }
-
Now tell composer to download TweeCdn by running the command:
$ php composer.phar update
Post installation
Enabling it in your "application.config.php" file.
```php
<?php
return array(
'modules' => array(
// ...
'TweeCdn',
),
// ...
);
```
Advanced configuration
- type - cdn type
- public_dir - path to public dir
- hostnames - list available hostnames
- hashes - hash list (file_path => hash)
- mapping - map specific to filepath to global CDNs: Google/NetDNA/MaxCDN
Options hostnames - support ALL cdn helpers.
-
Simple (default mode) Simple adds ?timestamp marker to the end of file Original
/css/simple.css
tranfromed to
/css/simple.css?1353231966Configuration with mapping jquery to google CDN (https://developers.google.com/speed/libraries/devguide)
<?php return array( 'di' => array( 'instance' => array( 'TweeCdn\View\Helper\Cdn' => array( 'parameters' => array( // simple configuration 'type' => 'simple', 'options' => array( 'public_dir' => __DIR__ . '/../../../../public', 'mappings' => array( '/js/jquery.js' => '//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js' ), ), ), ), ), ), );
-
Release Release based helper puts release number stored in file "/RELEASE" right after first folder name. As result you have unique path every release. (RELEASE file by default created by Remote multi-server automation tool - Capistrano) Original
/css/simple.css
tranfromed to
/css/1353231966/simple.css
Configuration
<?php return array( 'di' => array( 'instance' => array( 'TweeCdn\View\Helper\Cdn' => array( 'parameters' => array( // simple configuration 'release' => 'release', 'options' => array( 'public_dir' => __DIR__ . '/../../../../public', 'release' => trim(file_get_contents(__DIR__ . '/../../../../REVISION')), ), ), ), ), ), );
-
Hash Hash provides almost the same to "release" but uses unique file content hash. It can works in 2 mode:
- dynamic - when hashed generates in fly
- pre-compiled - by using existed hash map For "pre-compiled" mode you can generate hash map files by using script. it creates tmp/hashes.php files list. Eventully it makes application faster because you make less IO disk by skiping files md5 calculation every request.
vendor/bin/hash_collector.php
Original
/css/simple.css
tranfromed to
/css/72e7d8fb348a326251c37821d1b6bfe16ea69d6e/simple.css
Configuration sample with fail-back protection of missed tmp/hashes.php file and hostnames. The files will be spreaded by cdn-0 and cdn-1 by random depends on filename.
<?php return array( 'di' => array( 'instance' => array( 'TweeCdn\View\Helper\Cdn' => array( 'parameters' => array( // simple configuration 'release' => 'hash', 'options' => array( 'public_dir' => __DIR__ . '/../../../../public', 'hostnames' => array('http://cdn-0.coockieless.domain.com', 'http://cdn-1.coockieless.domain.com'), 'hashes' => (file_exists(__DIR__ . '/../tmp/hashes.php')) ? include __DIR__ . '/../tmp/hashes.php' : array(), ), ), ), ), ), );
truesocialmetrics/cdn 适用场景与选型建议
truesocialmetrics/cdn 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.87k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2018 年 12 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cdn」 「helper」 「content」 「delivery」 「laminas」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 truesocialmetrics/cdn 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 truesocialmetrics/cdn 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 truesocialmetrics/cdn 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A block that displays featured content - large image, title, description and link.
Datetime helpers for timezone handling
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
Library with classes to help you do batch.
This adds functions about array. If you feel like there few php built-in functions about array, this will be useful.
HTML and form generation
统计信息
- 总下载量: 7.87k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-12-28