PHP code example of knplabs / packagist-api
1. Go to this page and download the library: Download knplabs/packagist-api library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
knplabs / packagist-api example snippets
$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
...
$client->search('sylius', [], 2) // get first 2 pages
$package = $client->get('sylius/sylius');
printf(
'Package %s. %s.',
$package->getName(),
$package->getDescription()
);
// Outputs:
Package sylius/sylius. Modern ecommerce for Symfony2.
$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.
foreach ($client->all() as $package) {
echo $package;
}
// Outputs:
abhinavsingh/jaxl
abishekrsrikaanth/fuel-util
abmundi/database-commands-bundle
...
$client->all(array('type' => 'library'));
$client->all(array('vendor' => 'sylius'));
$client->setPackagistUrl('https://custom.packagist.site.org');