An easy way to get vendor and package data from Packagist via API calls

Overview

Laravel Packagist

Laravel Packagist

Laravel Packagist (LaravelPackagist) is a package for Laravel 5 to interact with the packagist api quickly and easily.

Latest Stable Version Total Downloads Travis-CI Build StyleCI Scrutinizer Build Status Scrutinizer Code Quality MadeWithLaravel.com shield License

Table of contents

Features

Laravel Packagist Features
Quicky start pulling vendor data from packagist via the API
Quicky start pulling package data from packagist via the API
Can use laravel built in cache to make it even faster
Config options extend to .env file
Uses localization language files

Requirements

Installation Instructions

  1. From your projects root folder in terminal run:

        composer require jeremykenedy/laravel-packagist
  2. Register the package

  • Laravel 5.5 and up Uses package auto discovery feature, no need to edit the config/app.php file.

  • Laravel 5.4 and below Register the package with laravel in config/app.php under providers with the following:

    'providers' => [
        jeremykenedy\LaravelPackagist\LaravelPackagistServiceProvider::class,
    ];
  1. Optionally publish the packages views, config file, assets, and language files by running the following from your projects root folder:

Publish All Assets

    php artisan vendor:publish --provider="jeremykenedy\LaravelPackagist\LaravelPackagistServiceProvider"

Publish Specific Assets

    php artisan vendor:publish --tag=laravelpackagist-config
    php artisan vendor:publish --tag=laravelpackagist-lang

Usage

  1. Add the following to the head of the file you are calling the methods from:
use jeremykenedy\LaravelPackagist\App\Services\PackagistApiServices;

File Example:

<?php

namespace App\Services\Sections;

use jeremykenedy\LaravelPackagist\App\Services\PackagistApiServices;
  1. Call the methods with the following:
// Vendors
PackagistApiServices::getPackagistVendorRepositoriesList('VENDOR-NAME-HERE');
PackagistApiServices::getVendorPackagesCount('VENDOR-NAME-HERE');
PackagistApiServices::getVendorsPackagesDetails('VENDOR-NAME-HERE');
PackagistApiServices::getVendorsTotalDownloads('VENDOR-NAME-HERE');
PackagistApiServices::getVendorsTotalStars('VENDOR-NAME-HERE');

// Individual Packages
PackagistApiServices::getPackageDownloads('VENDOR-NAME-HERE/PACKAGE-NAME-HERE');
PackagistApiServices::getPackageDailyDownloads('VENDOR-NAME-HERE/PACKAGE-NAME-HERE');
PackagistApiServices::getPackageMonthlyDownloads('VENDOR-NAME-HERE/PACKAGE-NAME-HERE');
PackagistApiServices::getPackageTotalDownloads('VENDOR-NAME-HERE/PACKAGE-NAME-HERE');
PackagistApiServices::getPackageTotalForks('VENDOR-NAME-HERE/PACKAGE-NAME-HERE');
PackagistApiServices::getPackageTotalOpenIssues('VENDOR-NAME-HERE/PACKAGE-NAME-HERE');
PackagistApiServices::getPackageTotalRepo('VENDOR-NAME-HERE/PACKAGE-NAME-HERE');
PackagistApiServices::getPackageTotalStars('VENDOR-NAME-HERE/PACKAGE-NAME-HERE');
PackagistApiServices::getPackageTotalWatchers('VENDOR-NAME-HERE/PACKAGE-NAME-HERE');
PackagistApiServices::getVendorsPackageDetails('VENDOR-NAME-HERE/PACKAGE-NAME-HERE');

Configuration

There are many configurable options which have all been extended to be able to configured via .env file variables. Editing the configuration file directly is not needed becuase of this.

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Packagist Caching Settings
    |--------------------------------------------------------------------------
    */
    'caching' => [
        'enabled'               => env('PACKAGIST_CACHE_ENABLED', TRUE),
        'vendorListCacheTime'   => env('PACKAGIST_VENDOR_LIST_CACHE_TIME_MINUTES', 100),
        'vendorItemCacheTime'   => env('PACKAGIST_VENDOR_ITEM_CACHE_TIME_MINUTES', 100),
    ],

    /*
    |--------------------------------------------------------------------------
    | Packagist CURL Settings
    |--------------------------------------------------------------------------
    */
    'curl' => [
        'timeout'       => env('PACKAGIST_CURL_TIMEOUT', 30),
        'maxredirects'  => env('PACKAGIST_CURL_MAX_REDIRECTS', 10),
    ],

    /*
    |--------------------------------------------------------------------------
    | Packagist API URLS
    |--------------------------------------------------------------------------
    */
    'urls' => [
        'vendorBase' => env('PACKAGIST_API_VENDOR_URL_BASE', 'https://packagist.org/packages/list.json?vendor='),
        'projectPreFix' => env('PACKAGIST_API_VENDOR_PROJECT_BASE_PREFIX', 'https://packagist.org/packages/'),
        'projectPostFix' => env('PACKAGIST_API_VENDOR_PROJECT_BASE_POSTFIX', '.json'),
    ],

    /*
    |--------------------------------------------------------------------------
    | Packagist default vendor
    |--------------------------------------------------------------------------
    */
    'vendor' => [
        'default' => env('PACKAGIST_DEFAULT_VENDOR', 'jeremykenedy'),
    ],

    /*
    |--------------------------------------------------------------------------
    | Packagist logging
    |--------------------------------------------------------------------------
    */
    'logging' => [
        'curlErrors' => env('PACKAGIST_LOG_CURL_ERROR', TRUE),
    ],
Environment File
PACKAGIST_CACHE_ENABLED=TRUE
PACKAGIST_VENDOR_LIST_CACHE_TIME_MINUTES=100
PACKAGIST_VENDOR_ITEM_CACHE_TIME_MINUTES=100
PACKAGIST_CURL_TIMEOUT=30
PACKAGIST_CURL_MAX_REDIRECTS=10
PACKAGIST_API_VENDOR_URL_BASE='https://packagist.org/packages/list.json?vendor='
PACKAGIST_API_VENDOR_PROJECT_BASE_PREFIX='https://packagist.org/packages/'
PACKAGIST_API_VENDOR_PROJECT_BASE_POSTFIX='.json'
PACKAGIST_DEFAULT_VENDOR='jeremykenedy'
PACKAGIST_LOG_CURL_ERROR=TRUE

File Tree

├── .gitignore..git
├── .travis.yml
├── LICENSE
├── README.md
├── composer.json
├── phpunit.xml
└── src
    ├── App
    │   ├── Services
    │   │   └── PackagistApiServices.php
    │   └── Traits
    │       └── PackagistApiTrait.php
    ├── LaravelPackagistFacade.php
    ├── LaravelPackagistServiceProvider.php
    ├── config
    │   └── laravelpackagist.php
    └── resources
        └── lang
            └── en
                └── laravelpackagist.php
  • Tree command can be installed using brew: brew install tree
  • File tree generated using command tree -a -I '.git|node_modules|vendor|storage|tests'

License

Laravel Packagist is licensed under the MIT license. Enjoy!

You might also like...
This package aims to help you standardize all your API responses in a simple and structured way.

Laravel API Response This package aims to help you standardize all your API responses in a simple and structured way. By default, the stucture of the

Laravel Serializable Closure provides an easy way to serialize closures in PHP.

Serializable Closure Introduction This package is a work in progress Laravel Serializable Closure provides an easy way to serialize closures in PHP. I

An easy way to integrate Google Maps with Laravel

An easy way to integrate Google Maps with Laravel For Laravel 5.x, check version 2.35.1 For Laravel 4.x, check version 1.27.0 Think of Googlmapper as

Laravel Breadcrumbs - An easy way to add breadcrumbs to your @Laravel app.

Introduction Breadcrumbs display a list of links indicating the position of the current page in the whole site hierarchy. For example, breadcrumbs lik

🏭 An easy way to generate populated factories for models.
🏭 An easy way to generate populated factories for models.

Laravel Populated Factory provides an easy way to generate populated factories for models according to types & names of their columns. Install You can

An easy way to add colors in your CLI scripts.
An easy way to add colors in your CLI scripts.

COLORS Here is a preview of what you can achieve with the library: Installation Installation via composer is highly recommended. { "require": {

Easy way to upload Laravel model related files from the request.

Easy way to upload laravel model related file from the requset.

Laravel SEO - This is a simple and extensible package for improving SEO via meta tags, such as OpenGraph tags.

This is a simple and extensible package for improving SEO via meta tags, such as OpenGraph tags.

LERN is a Laravel package that will record exceptions into a database and will notify you via Email, Pushover or Slack.

LERN is a Laravel package that will record exceptions into a database and will notify you via Email, Pushover or Slack.

Owner
Jeremy Kenedy
Love programming everyday. Practice compassion and kindness to all. Striving to be a better person and father. Love giving back and helping others.
Jeremy Kenedy
A customisable Laravel Nova card that fetches data through ajax calls.

Ajax Table Card Description A customisable Laravel Nova card that fetches data through ajax calls. Why? To allow displaying certain data on the dashbo

TwentyOne34 Technologies Corp. 4 Mar 8, 2022
📦 Adds Laravel Packages Support to Lumen and Vendor Publish Artisan Command.

Laravel Package Support for Lumen: Makes Lumen compatible with Laravel Packages. You can use any Laravel Packages in Lumen by installing Larasupport Package.

Irfaq Syed 127 Dec 17, 2022
A simple pure PHP RADIUS client supporting Standard and Vendor-Specific Attributes in single file

BlockBox-Radius A simple pure PHP RADIUS client supporting Standard and Vendor-Specific Attributes in single file Author: Daren Yeh [email protected]

null 2 Oct 2, 2022
Laravel Setting - Easily save, update and get titles, descriptions, and more. it is very easy to use.

Laravel Setting Easily save, update and get titles, descriptions, and more. it is very easy to use. This is great for storing and receiving general si

Ali Ranjbar 2 Aug 23, 2022
Removes whitelisted unnecessary files (like tests/docs etc.) from vendor directory

Composer vendor cleanup This is a simple script for the Composer to remove unnecessary files (documentation/examples/tests etc.) from included vendor

Chris 2 Nov 14, 2022
Easy Way to integrate API in you laravel application.

Easy Api Easy Way to integrate API in you laravel application. Installation Guide Install Package using Composer. composer require flutterbuddy1/easy-

Mayank Diwakar 1 Oct 9, 2022
Save Model is a Laravel package that allows you to save data in the database in a new way.

Save Model is a Laravel package that allows you to save data in the database in a new way. No need to worry about $guarded and $fillable properties in the model anymore. Just relax an use Save Model package.

Laratips 27 Mar 2, 2022
Collection of the Laravel/Eloquent Model classes that allows you to get data directly from a Magento 2 database.

Laragento LAravel MAgento Micro services Magento 2 has legacy code based on abandoned Zend Framework 1 with really ugly ORM on top of outdated Zend_DB

Egor Shitikov 87 Nov 26, 2022
An abstraction layer to get data from array or a file with dot-notation

Alex Unruh - Config This library is based on the Laravel config concept. It values performance and was built on top of the library Dflydev Dot Access

Alexandre Odair 3 May 20, 2022
Laravel Package for TMDB ( The Movie Database ) API. Provides easy access to the wtfzdotnet/php-tmdb-api library.

Laravel Package for TMDB API Wrapper A Laravel package that provides easy access to the php-tmdb/api TMDB (The Movie Database) API wrapper. This packa

PHP - The Movie Database 151 Nov 1, 2022