jeremykenedy / laravel-packagist
Fund package maintenance!
jeremykenedy
Patreon
Installs: 250
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 3
Forks: 3
Open Issues: 0
Type:package
Requires
- php: >=7.1.3
This package is auto-updated.
Last update: 2024-12-15 11:56:38 UTC
README
Laravel Packagist
Laravel Packagist (LaravelPackagist) is a package for Laravel 5 to interact with the packagist api quickly and easily.
Table of contents
Features
Requirements
Installation Instructions
-
From your projects root folder in terminal run:
composer require jeremykenedy/laravel-packagist
-
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
underproviders
with the following:
'providers' => [ jeremykenedy\LaravelPackagist\LaravelPackagistServiceProvider::class, ];
- 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
- 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;
- 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.
- See config file: laravelpackagist.php.
<?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!