ovk/fastly-php
Composer 安装命令:
composer require ovk/fastly-php
包简介
Provides a PHP client for the Fastly API
README 文档
README
Installation via Composer
The recommended method to install Fastly-PHP is through Composer.
-
Add
ovk/fastly-phpas a dependency in your project'scomposer.json:{ "require": { "ovk/fastly-php": "~1.0.0" } } -
Download and install Composer:
curl -s http://getcomposer.org/installer | php -
Install your dependencies:
php composer.phar install --no-dev
-
Require Composer's autoloader
Composer also prepares an autoload file that's capable of autoloading all of the classes in any of the libraries that it downloads. To use it, just add the following line to your code's bootstrap process:
<?php require 'vendor/autoload.php'; $adapter = new GuzzleAdapter('fastly-api-key'); $client = new Fastly($adapter, "default-service-id");
You can find out more on how to install Composer, configure autoloading, and other best-practices for defining dependencies at getcomposer.org.
You'll notice that the installation command specified --no-dev. This prevents Composer from installing the various testing and development dependencies. For average users, there is no need to install the test suite. If you wish to contribute to development, just omit the --no-dev flag to be able to run tests.
Changelog v1.0.0
- Added Soft-purge support
- Added support to native batch hard purge
- Implemented async requests to speed up the purge process
- Changed the output: It is always a decoded json from fastly's response.
Example
$adapter = new GuzzleAdapter('fastly-api-key'); $fastly = new Fastly($adapter, 'my-service-id'); $result = $fastly->send('GET', 'stats?from=1+day+ago'); $result = $fastly->purgeAll();
// Purge multiple urls $result = $fastly->purge(['url1', 'url2', 'url3']);
// Purge multiple tags $result = $fastly->purgeKey(['tag1', 'tag2', 'tag3']);
// Softpurge multiple tags $result = $fastly->softPurgeKey(['tag1', 'tag2', 'tag3']);
To target a different service than the default configured:
$result = $fastly->service('another-service-id')->softPurgeKey(['tag1', 'tag2', 'tag3']);
$result is always an array of decodified fastly's json response.
To retreive errors:
$errors = $fastly->getError();
Adapters
This packages uses Guzzle as the default http client.
To use a different http client an adapter class that implements implementing Fastly\Adapter\AdapterInterface should be provided.
License
This package uses the MIT License (MIT). Please see LICENSE for more information.
ovk/fastly-php 适用场景与选型建议
ovk/fastly-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 131 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 01 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 ovk/fastly-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ovk/fastly-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 131
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-01-19