Skip to content

LibrariesIO - A simple API wrapper/client for the Libraries.io API.

License

Notifications You must be signed in to change notification settings

ericsizemore/librariesio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LibrariesIO - A simple API wrapper/client for the Libraries.io API.

Build Status Code Coverage Scrutinizer Code Quality Continuous Integration Type Coverage Psalm Level PHPMD Latest Stable Version Downloads per Month License

2.0.0 Important Note

  • The master branch is for development of the upcoming version 2.0.0.
    • This is a notable exception to the backward compatibility promise, as most of this work was done before it was implemented.
  • Should be relatively stable, but would still advise against using in production.
  • Function parameters, class api's, etc. may change during development.
  • The docs have not yet been fully updated with changes.

Important Note

This project was born from the desire to expand my knowledge of API's and GuzzleHttp. My implementation is far from perfect, so I am open to any and all feedback that one may wish to provide.

  • The Libraries.io API has the ability for pagination, however it is not yet fully implemented in this library.

Installation

Composer

Install the latest version with:

$ composer require esi/librariesio

Then, within your project (if not already included), include composer's autoload. For example:

<?php

require 'vendor/autoload.php';

?>

For more information see the installation docs.

Basic Usage

LibrariesIO splits the different endpoints based on their "component":

  • Esi\LibrariesIO\LibrariesIO::platform()
    • does not require an $endpoint, though you can pass 'platforms'.
  • Esi\LibrariesIO\LibrariesIO::project()
    • takes an 'endpoint' parameter to specify which subset you are looking for.
      • Current endpoints are:
        • contributors
        • dependencies
        • dependents
        • dependent_repositories
        • project
        • search
        • sourceRank
  • Esi\LibrariesIO\LibrariesIO::repository()
    • takes an 'endpoint' parameter to specify which subset you are looking for.
      • Current endpoints are:
        • dependencies
        • projects
        • repository
  • Esi\LibrariesIO\LibrariesIO::user()
    • takes an 'endpoint' parameter to specify which subset you are looking for.
      • Current endpoints are:
        • dependencies
        • packages
        • package_contributions
        • repositories
        • repository_contributions
        • subscriptions
        • user
  • Esi\LibrariesIO\LibrariesIO::subscription()
    • takes an 'endpoint' parameter to specify which subset you are looking for.
      • Current endpoints are:
        • subscribe
        • check
        • update
        • unsubscribe

Each 'subset' has their own required options. Check the documentation (currently WIP) for more information.

As an example, let's say you want to get a list of the available platforms. To do so:

<?php

use Esi\LibrariesIO\LibrariesIO;
use Esi\LibrariesIO\Utils;

$api = new LibrariesIO('..yourapikey..', \sys_get_temp_dir());
$response = $api->platform();

print_r(Utils::toArray($response));

/*
Array
(
    [0] => Array
        (
            [name] => NPM
            [project_count] => 4079049
            [homepage] => https://www.npmjs.com
            [color] => #f1e05a
            [default_language] => JavaScript
        )

    [1] => Array
        (
            [name] => Maven
            [project_count] => 588275
            [homepage] => http://maven.org
            [color] => #b07219
            [default_language] => Java
        )
    [...]
)
*/
?>

For more information see the basic usage docs.

Documentation

The docs/ folder or online here.

About

Requirements

  • LibrariesIO works with PHP 8.2.0 or above.
  • All API requests include an api_key parameter. You will need to get your api key from your account page at libraries.io.

Credits

Contributing

See CONTRIBUTING.

Bugs and feature requests are tracked on GitHub.

Contributor Covenant Code of Conduct

See CODE_OF_CONDUCT.md

Backward Compatibility Promise

See backward-compatibility.md for more information on Backwards Compatibility.

Changelog

See the CHANGELOG for more information on what has changed recently.

License

See the LICENSE for more information on the license that applies to this project.

Security

See SECURITY for more information on the security disclosure process.