knplabs/packagist-api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

knplabs/packagist-api

Composer 安装命令:

composer require knplabs/packagist-api

包简介

Packagist API client.

README 文档

README

Build status Latest Stable Version Total Downloads

Simple object oriented wrapper for Packagist API.

Requirements

  • PHP ^7.4 or ^8.0 (for PHP 7.1-7.3 please use the 1.x release line)

Installation

The recommended way to install Packagist API is through composer:

composer require knplabs/packagist-api

Usage

Search for packages:

<?php

$client = new Packagist\Api\Client();

foreach ($client->search('sylius') as $result) {
    echo $result->getName();
}

// Outputs:
sylius/sylius
sylius/resource-bundle
sylius/cart-bundle
sylius/flow-bundle
sylius/sales-bundle
sylius/shipping-bundle
sylius/taxation-bundle
sylius/money-bundle
sylius/assortment-bundle
sylius/addressing-bundle
sylius/payments-bundle
sylius/taxonomies-bundle
sylius/inventory-bundle
sylius/settings-bundle
sylius/promotions-bundle
...

You can limit results to a desired amount of pages:

<?php

$client->search('sylius', [], 2)  // get first 2 pages

Get package details:

Gets full package details, generated dynamically by the Packagist API. Consider using getComposer() instead to use the Packagist API more efficiently if you don't need all the full metadata for a package.

<?php

$package = $client->get('sylius/sylius');

printf(
    'Package %s. %s.',
    $package->getName(),
    $package->getDescription()
);

// Outputs:
Package sylius/sylius. Modern ecommerce for Symfony2.

Get composer details: {#get-composer-details}

Similar to get(), but uses Composer metadata which is Packagist's preferred way of retrieving details, since responses are cached efficiently as static files by the Packagist service. The response lacks some metadata that is provided by get(), see Packagist API documentation for details. Returns multiple packages, you need to select the requested one from the indexed array.

<?php

$packages = $client->getComposer('sylius/sylius');
$package = $packages['sylius/sylius'];
$versions = $package->getVersions();

printf(
    'Package %s. %s.',
    $versions[0]->getName(),
    $versions[0]->getDescription()
);

// Outputs:
Package sylius/sylius. Modern ecommerce for Symfony2.

List all packages:

<?php

foreach ($client->all() as $package) {
    echo $package;
}

// Outputs:
abhinavsingh/jaxl
abishekrsrikaanth/fuel-util
abmundi/database-commands-bundle
...

They can be filtered by type or vendor:

<?php

$client->all(array('type' => 'library'));
$client->all(array('vendor' => 'sylius'));

Custom Packagist repositories

You can also set a custom Packagist repository URL:

<?php

$client->setPackagistUrl('https://custom.packagist.site.org');

Errors

  • A Packagist\Api\PackageNotFoundException will be thrown when the Packagist API returns a 404 response.
  • An \InvalidArgumentException will be thrown when the response from Packagist was not able to be parsed.

License

packagist-api is licensed under the MIT License - see the LICENSE file for details.

Maintainers

KNPLabs is looking for maintainers (see why).

If you are interested, feel free to open a PR to ask to be added as a maintainer.

We’ll be glad to hear from you :)

This library is maintained by the following people (alphabetically sorted) :

  • @robbieaverill

knplabs/packagist-api 适用场景与选型建议

knplabs/packagist-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.46M 次下载、GitHub Stars 达 182, 最近一次更新时间为 2013 年 03 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「api」 「composer」 「packagist」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 1.46M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 187
  • 点击次数: 25
  • 依赖项目数: 44
  • 推荐数: 1

GitHub 信息

  • Stars: 182
  • Watchers: 23
  • Forks: 45
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-03-17