tjvb/laravel-dashboard-packagist-tile

A tile for Laravel Dashboard that shows statistics from packagist.

1.8.0 2023-11-24 10:49 UTC

This package is auto-updated.

Last update: 2024-09-15 20:40:57 UTC


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

Latest Stable Version Pipeline status Coverage report Tested on PHP 7.4 to 8.3 Tested on Laravel 9 to 10 Latest Unstable Version

PHP Version Require Laravel Version Require Livewire Version Require PHPMD PHPCS

License

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>

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

License

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