承接 upstreamable/jsdelivr-api-client 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

upstreamable/jsdelivr-api-client

Composer 安装命令:

composer require upstreamable/jsdelivr-api-client

包简介

Client for the jsDelivr data API https://github.com/jsdelivr/data.jsdelivr.com

README 文档

README

A simple PHP client to use the JsDelivr API.

Requirements

  • PHP >= 7.2
  • Composer

Installation

We use HTTPPlug as the HTTP client abstraction layer. In this example, we will use Guzzle v6 as the HTTP client implementation.

jsdelivr-api-client uses Composer. The first step to use jsdelivr-api-client is to download composer:

$ curl -s http://getcomposer.org/installer | php

Then, run the following command to require the library:

$ php composer.phar require upstreamable/jsdelivr-api-client php-http/guzzle6-adapter:^2.0

If you want to use another HTTP client implementation, you can check here the full list of HTTP client implementations.

Getting started

Initialise the client

<?php

require_once __DIR__ . '/vendor/autoload.php';

$client = (new \Upstreamable\JsdelivrApiClient\JsdelivrApiClientBuilder())->buildClient();

By default it will use the API at data.jsdelivr.com and fetch information from NPM.

When complete URLs are requested they will use the https://cdn.jsdelivr.net domain.

You can configure the above

<?php

$client = (new \Upstreamable\JsdelivrApiClient\JsdelivrApiClientBuilder('https://data.example.com/v1/', 'gh', 'https://cdn.example.net'))->buildClient();

List package versions

$versions = $client->getVersionsApi()->getVersions('jquery');
print_r($versions);

List tags

$tags = $client->getVersionsApi()->getTags('jquery');
print_r($tags);

List package files

// Get a tree file structure.
$files = $client->getVersionFilesApi()->get('jquery', '3.2.1');
print_r($files);

// Using github and also a flat structure.
$files = $client->getVersionFilesApi()->get('twbs/bootstrap', '3.2.1', 'flat');
print_r($files);

// Get the default file (the 'main' key from package.json).
$file = $client->getVersionFilesApi()->getDefault('jquery', '3.2.1');
print_r($file);

// Get the files with complete URL indexed by relative path. This call returns the flat format.
$files = $client->getVersionFilesApi()->getCompleteUri('twbs/bootstrap', '3.2.1');
print_r($files);

// This will return a structure like

[
...
  "/dist/core.js" => "https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/core.js"
  "/dist/jquery.js" => "https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.js"
  "/dist/jquery.min.js" => "https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js"
  "/dist/jquery.min.map" => "https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.map"
  "/dist/jquery.slim.js" => "https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.slim.js"
  "/dist/jquery.slim.min.js" => "https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.slim.min.js"
  "/dist/jquery.slim.min.map" => "https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.slim.min.map"
...
]

Resolve version range

$version = $client->getResolveVersionApi()->get('jquery', '3');
print_r($version);

Testing

Install composer

Run:

composer install
vendor/bin/phpunit -c phpunit.dist.xml
vendor/bin/php-cs-fixer fix --diff --dry-run --config=.php_cs.php -vvv

Support

The support of this client is made in best effort by volunteers not associated with the JsDelivr developers.

If you find a bug or want to submit an improvement, don't hesitate to raise an issue on GitLab.

Credits

Based on the structure of the Akeneo API client

upstreamable/jsdelivr-api-client 适用场景与选型建议

upstreamable/jsdelivr-api-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.09k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 02 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 upstreamable/jsdelivr-api-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 upstreamable/jsdelivr-api-client 我们能提供哪些服务?
定制开发 / 二次开发

基于 upstreamable/jsdelivr-api-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 8.09k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 17
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2019-02-28