tjvb/laravel-dashboard-packagist-tile

A tile for Laravel Dashboard that shows statistics from packagist.

1.2.0 2020-09-17 20:48 UTC

This package is auto-updated.

Last update: 2020-09-21 12:07:27 UTC


README

Latest Version on Packagist pipeline status coverage report

Packagist data tile screenshot

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>

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

License

The MIT License (MIT). Please see License File for more information.