tjvb / laravel-dashboard-packagist-tile
A tile for Laravel Dashboard that shows statistics from packagist.
Requires
- php: ^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0
- illuminate/support: ^7.0 || ^8.0 || ^9.0 || ^10.0
- livewire/livewire: ^1.0 || ^2.0
- spatie/laravel-dashboard: ^1.0 || ^2.0
- spatie/packagist-api: ^2.0
Requires (Dev)
- fakerphp/faker: ^1.9
- orchestra/testbench: ^5.2 || ^6.0 || ^7.0 || ^8.0
- phpmd/phpmd: ^2.13
- phpunit/phpunit: ^9.0
- squizlabs/php_codesniffer: ^3.5
README
This package will not be updated without new maintainers, see: https://gitlab.com/tjvb/laravel-dashboard-packagist-tile/-/issues/10
Show packagist downloads in a tile on Spatie Laravel downloads
This tile can be used on the Laravel Dashboard to show packagist statistics about the package you like to see. You can hide abandoned package and the totals for the packages. It also support pagination.
Installation
You can install the package via composer:
composer require tjvb/laravel-dashboard-packagist-tile
In the dashboard
config file, you must add this configuration in the tiles
key. And customize it for your own needs.
// in config/dashboard.php
return [
'tiles' => [
'packagist' => [
'refresh_interval_in_seconds' => 300,
'sort' => 'total', // options: name, daily, monthly, total, empty means no sorting.
'reverse' => true, // reverse the order
'with_abandoned' => true, // set to false to ignore them
'display' => [
'totals' => true,
'faves' => true, // packagist faces
'github_stars' => true, // github stars
],
'vendors' => [ // vendors from which you want to see all the packages
'tjvb',
'spatie',
],
'packages' => [ // specific packages that you want to see.
'phpmd/phpmd',
'pdepend/pdepend',
],
],
],
];
To load the data from packagist there are two commands to schedule. The FetchPackageDataCommand gets the statistics for the package. This is cached for twelve hours so it isn't usefull to get it more then twice a day. See the Packagist API documentation
The second command is to get the packages for the vendors that you have configured. If you create a lot of packages like the great people from Spatie it can be usefull to automate it. Else it is preferable to run php artisan dashboard:fetch-vendor-packages-from-packagist
after you publish a new package on packagist.
// in app/console/Kernel.php
protected function schedule(Schedule $schedule)
{
// ...
$schedule->command(\TJVB\PackagistTile\FetchPackageDataCommand::class)->twiceDaily();
// Additional if the vendors you watch release a lot of packages.
// Else be nice and do it manually with php artisan dashboard:fetch-vendor-packages-from-packagist.
// $schedule->command(\TJVB\PackagistTile\FetchVendorPackagesCommand::class)->daily();
}
Usage
In your dashboard view you use the livewire:packagist-tile
component.
<x-dashboard>
<livewire:packagist-tile position="e7:e16" />
</x-dashboard>
Pagination
The packages are paginated, by default a page has a maximum of 10 packages. This can be changed with adding a perPage property to the tile.
<x-dashboard>
<livewire:packagist-tile position="e7:e16" perPage="2" />
</x-dashboard>
Customizing the view
If you want to customize the view used to render this tile, run this command:
php artisan vendor:publish --provider="TJVB\PackagistTile\PackagistTileServiceProvider" --tag="dashboard-packagist-views"
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email info@tjvb.nl instead of using the issue tracker.
Credits
Thanks to
- Spatie for the dashboard and packagist api package.
- Packagist for the great service.
- Frontend preset for Tailwind CSS For the pagination preset.
License
The MIT License (MIT). Please see License File for more information.