Giter Site home page Giter Site logo

laravel-packagist's Introduction

Laravel Packagist

MIT Licensed Latest Stable Version Build status Coverage StyleCI Total Downloads

A Laravel wrapper for the spatie/packagist-api package.

Installation

You can install this package with composer:

composer require markwalet/laravel-packagist

Laravel uses Package auto-discovery, so you don't have to register the service provider. If you want to register the service provider manually, add the following line to your config/app.php file:

MarkWalet\Packagist\PackagistServiceProvider::class,

Usage

There are two main ways how you can make Packagist calls:

Using the application container

/** @var \Spatie\Packagist\PackagistClient $client */
$client = app(\Spatie\Packagist\PackagistClient::class);

$client->getPackage('markwalet', 'laravel-packagist');

Using the facade

Packagist::getPackage('markwalet', 'laravel-packagist');

Available methods

List package names

// All packages
Packagist::getPackagesNames();

// Filter on type.
Packagist::getPackagesNamesByType('composer-plugin');

// Filter on organization
Packagist::getPackagesNamesByVendor('markwalet');

Searching for packages

// Search packages by name.
Packagist::searchPackagesByName('packagist');

// Search packages by tag.
Packagist::searchPackagesByTags('psr-3');

// Search packages by type.
Packagist::searchPackagesByType('composer-plugin');

// Combined search.
Packagist::searchPackages('packagist', ['type' => 'library']);

Pagination

Searching for packages returns a paginated result. You can change the pagination settings by adding more parameters.

// Get the third page, 10 items per page.
Packagist::searchPackagesByName('packagist', 3, 10);

Getting package data.

// Using the Composer metadata. (faster, but less data)
Packagist::getPackageMetadata('markwalet/laravel-packagist');
Packagist::getPackageMetadata('markwalet', 'laravel-packagist');

// Using the API. (slower, cached for 12 hours by Packagist.
Packagist::getPackage('markwalet/laravel-packagist');
Packagist::getPackage('markwalet', 'laravel-packagist');

Get Statistics

$packagist->getStatistics();

Configuration

By default, the api url for Packagist is set to https://packagist.org. If you want to override that, you can add the following code block to your config/services.php file:

'packagist' => [
    'base_url' => 'https://packagist.org',
    'repo_url' => 'https://repo.packagist.org',
],

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.