drupol/composer-packages
Composer 安装命令:
composer require drupol/composer-packages
包简介
Composer Packages is a Composer plugin for getting information about installed packages in your project.
关键字:
README 文档
README
Composer Packages
Description
Composer Packages is a Composer plugin for getting information about installed packages in your project.
It could be very useful for anyone who wants to build a package discovery system, crawling the filesystem is then not needed.
Documentation
This package provides:
- An easy way to get information about installed packages,
- An easy way to retrieve packages that has a particular types,
- An easy way to find the installation directory of a package,
- An easy way to get any package version,
- An easy way to get any package dependencies.
How does it work ?
When doing a composer update or composer install, the plugin will generate
classes that are going to be automatically loaded by the Composer autoload
system.
Those classes contains statical information about packages that are installed in your project. Among those static data, it also contains some useful methods. The number of methods in those classes can very depending on the number of packages that are in your project.
This package idea has been inspired by the package ocramius/package-versions from the amazing Marco Pivetta.
Requirements
- PHP $\geq$ 7.1.3
Installation
composer require drupol/composer-packages --dev
Usage
To get packages of a particular type
<?php declare(strict_types=1); include './vendor/autoload.php'; use ComposerPackages\Types; // Use your IDE auto completion to list all the available methods based on your installed packages. $packages = Types::library(); foreach ($packages as $package) { $package->getName(); // $package is an instance of Composer\Package\PackageInterface } // You can also get an array $packagesArray = iterator_to_array($packages);
To get a package
<?php declare(strict_types=1); include './vendor/autoload.php'; use ComposerPackages\Packages; use Composer\Package\PackageInterface; // Use your IDE auto completion to list all the available methods based on your installed packages. $package = Packages::symfonyProcess(); // Package is an instance of Composer\Package\PackageInterface then: $package->getName(); // To get the name. // Find all the packages where the name starts with the letter "c". $finder = static function (PackageInterface $package) : bool { return 'c' === str_split($package->getName())[0]; }; foreach (Packages::find($finder) as $package) { // Do something here. }
To get an installation directory
<?php declare(strict_types=1); include './vendor/autoload.php'; use ComposerPackages\Directories; // Use your IDE auto completion to list all the available methods based on your installed packages. $directory = Directories::symfonyProcess();
To get a package version
<?php declare(strict_types=1); include './vendor/autoload.php'; use ComposerPackages\Versions; // Use your IDE auto completion to list all the available methods based on your installed packages. $version = Versions::symfonyProcess();
To get a package dependencies
<?php declare(strict_types=1); include './vendor/autoload.php'; use ComposerPackages\Dependencies; // Use your IDE auto completion to list all the available methods based on your installed packages. $dependencies = Dependencies::symfonyDependencyInjection(); foreach ($dependencies as $dependency) { echo $dependency; // $dependency is string, the package name. } // You can also get an array $dependenciesArray = iterator_to_array($dependencies);
Note: If composer is not already installed, you might get an error like below when using this package:
In Types.php line […]:
Attempted to load class "ArrayLoader" from namespace "Composer\Package\Loader".
Did you forget a "use" statement for e.g. "…\ArrayLoader", "…\ArrayLoader" or "…\ArrayLoader"?
If you do, you can explicitly require composer in your project, to ensure it's available:
composer require composer/composer
To get a package version
<?php declare(strict_types=1); include './vendor/autoload.php'; use ComposerPackages\Versions; // Use your IDE auto completion to list all the available methods based on your installed packages. $version = Versions::symfonyProcess();
Code quality and tests
Every time changes are introduced into the library, Github run the tests and the benchmarks.
The library has tests written with PHPUnit.
Before each commit some inspections are executed with
GrumPHP, run ./vendor/bin/grumphp run to
trigger them manually.
PHPInfection is used to ensure that
your code is properly tested, run composer infection to test your code.
Contributing
Feel free to contribute by sending pull requests. We are a usually very responsive team and we will help you going through your pull request from the beginning to the end.
For some reasons, if you can't contribute to the code and willing to help, sponsoring is a good, sound and safe way to show us some gratitude for the hours we invested in this package.
Sponsor me on Github and/or any of the contributors.
drupol/composer-packages 适用场景与选型建议
drupol/composer-packages 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 285.03k 次下载、GitHub Stars 达 32, 最近一次更新时间为 2019 年 08 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「extension」 「composer plugin」 「Composer Helper」 「Packages discovery」 「Types discovery」 「Directories discovery」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 drupol/composer-packages 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 drupol/composer-packages 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 drupol/composer-packages 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
A custom URL rule class for Yii 2 which allows to create translated URL rules
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
UI Kit 3 Extension for Yii2
Adds more BBCode
统计信息
- 总下载量: 285.03k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 32
- 点击次数: 27
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-08-01