incapption/bunny-purge

Bunny CDN API 文件清理类

v1.0.0 2021-03-04 16:14 UTC

This package is auto-updated.

Last update: 2024-09-22 06:45:44 UTC


README

用于在BunnyCN (https://bunny.net) 上使用Guzzle HTTP客户端清理文件的微小包。

用法

$client = new BunnyPurge('YOUR_BUNNY_API_KEY');
$client->purge('https://example.b-cdn.net/example.jpg');

$client->purge() 在非200状态码时抛出 BunnyException,在请求异常时抛出 GuzzleException

测试

在项目目录中创建一个 phpunit.xml 文件,并添加您的API密钥和指向CDN上文件的测试URL的PHP变量。

<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
  <coverage>
    <include>
      <directory suffix=".php">src/</directory>
    </include>
  </coverage>
  <testsuites>
    <testsuite name="Project Test Suite">
      <directory>tests</directory>
    </testsuite>
  </testsuites>
  <php>
    <var name="API_KEY" value="YOUR_BUNNY_API_KEY"/>
    <var name="TEST_URL" value="https://example.b-cdn.net/example.jpg"/>
  </php>
</phpunit>