dev-master
9999999-devSimple Packagist API Client in PHP
MIT
The Requires
- php >=5.6
The Development Requires
by Raymond Rutjes
0.1.0
0.1.0.0Simple Packagist API Client in PHP
MIT
The Requires
- php >=5.6
The Development Requires
by Raymond Rutjes
Wallogit.com
2017 © Pedro Peláez
Simple Packagist API Client in PHP
Let's consume the Packagist API., (*1)
This library can be found on Packagist. The recommended way to install this is through composer., (*3)
Run these commands to install composer, the library and its dependencies:, (*4)
$ curl -sS https://getcomposer.org/installer | php $ php composer.phar require rayrutjes/packagist-api-client
You then need to install one of the following:, (*5)
$ php composer.phar require guzzlehttp/guzzle:~5.0 $ php composer.phar require guzzlehttp/guzzle:~6.0
<?php require 'vendor/autoload.php'; use PackagistApi\Client; use PackagistApi\Adapter\GuzzleHttpAdapter; // Create an adapter. $adapter = new GuzzleHttpAdapter(); // Create a Client object with the previous adapter. $packagist = new Client($adapter); // ...
Accepts the following optional parameters: - vendor - type, (*6)
<?php
// ... initialize Client like explained above.
$packageNames = $packagist->getAllPackageNames([
'vendor' => 'composer', // Optional.
'type' => 'composer-plugin', // Optional.
]);
var_dump($packageNames);
Will throw an PackagistApi\Exception\HttpException if the package does not exist., (*7)
<?php
// ... initialize Client like explained above.
$package = $packagist->getPackageByName('rayrutjes/packagist-api-client');
var_dump($package);
Accepts the following optional parameters: - q - tags - type - per_page - page, (*8)
<?php
// ... initialize Client like explained above.
$packages = $packagist->searchPackages([
'q' => 'monolog', // Optionally filter by name.
'tags' => 'psr-3', // Optionally filter by tag.
'type' => 'symfony-bundle', // Optionally filter by type.
'per_page' => 10, // Optionally change the number of results per page.
'page' => 3, // Optionally choose the results page.
]);
var_dump($packages);
// Iterate over all search results.
$packages = [];
$page = 1;
$limit = 500;
do {
$result = $packagist->searchPackages([
'q' => 'monolog', // Optionally filter by name.
'per_page' => 100, // Optionally change the number of results per page.
'page' => $page, // Optionally choose the results page.
]);
$packages = array_merge($packages, $result['results']);
++$page;
} while (isset($result['next']) && count($packages) <= $limit);
var_dump($packages);
Accepts the following optional parameters: - per_page - page, (*9)
<?php
// ... initialize Client like explained above.
$popularPackages = $packagist->getPopularPackages([
'per_page' => 10, // Optionally change the number of results per page.
'page' => 3, // Optionally choose the results page.
]);
var_dump($popularPackages);
// Iterate over all popular packages.
$packages = [];
$page = 1;
$limit = 500;
do {
$result = $packagist->getPopularPackages([
'per_page' => 100, // Optionally change the number of results per page.
'page' => $page, // Optionally choose the results page.
]);
$packages = array_merge($packages, $result['packages']);
++$page;
} while (isset($result['next']) && count($packages) <= $limit);
var_dump($packages);
Please see CONTRIBUTING for details., (*10)
Please see CHANGELOG for details., (*11)
Please open an issue in github, (*12)
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities., (*13)
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion., (*14)
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct., (*15)
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team., (*16)
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers., (*17)
This Code of Conduct is adapted from the Contributor Covenant, version 1.0.0, available at http://contributor-covenant.org/version/1/0/0/., (*18)
PackagistApi is released under the MIT License. See the bundled LICENSE file for details., (*19)
Simple Packagist API Client in PHP
MIT
Simple Packagist API Client in PHP
MIT