├── .gitignore ├── src ├── Classes │ └── PackageChecker.php ├── config │ └── package-checker.php ├── routes │ └── web.php ├── Providers │ └── PackageCheckerServiceProvider.php ├── Http │ ├── Controllers │ │ └── PackageCheckerController.php │ └── Services │ │ └── PackageCheckerService.php └── resources │ └── views │ └── list.blade.php ├── composer.json └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | vendor/ 3 | ``` -------------------------------------------------------------------------------- /src/Classes/PackageChecker.php: -------------------------------------------------------------------------------- 1 | [ 5 | 'prefix' => env('PACKAGE_CHECKER_ROUTES_PREFIX', 'package-checker'), 6 | 'middleware' => env('PACKAGE_CHECKER_ROUTES_MIDDLEWARE', ['web','auth']), 7 | 'namespace' => 'Iinmass\LaravelPackageChecker\Http\Controllers', 8 | ], 9 | ]; -------------------------------------------------------------------------------- /src/routes/web.php: -------------------------------------------------------------------------------- 1 | name('package-checker.list'); 6 | Route::get('/get-installed-packages', 'PackageCheckerController@getInstalledPackages')->name('package-checker.get-installed-packages'); 7 | Route::get('/get-package-details', 'PackageCheckerController@getPackageDetails')->name('package-checker.get-package-details'); 8 | Route::get('/get-latest-version', 'PackageCheckerController@getLatestVersion')->name('package-checker.get-latest-version'); 9 | Route::post('/get-size', 'PackageCheckerController@getPackageSize')->name('package-checker.get-size'); 10 | Route::get('/get-vendor-size', 'PackageCheckerController@getVendorSize')->name('package-checker.get-vendor-size'); 11 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "iinmass/laravel-package-checker", 3 | "description": "A powerful tool for managing package dependencies in Laravel projects. Get insights into package versions, installation status, and sizes.", 4 | "type": "library", 5 | "autoload": { 6 | "psr-4": { 7 | "Iinmass\\LaravelPackageChecker\\": "src/" 8 | } 9 | }, 10 | "keywords": [ 11 | "laravel", 12 | "package", 13 | "checker", 14 | "dependency", 15 | "management" 16 | ], 17 | "license": "MIT", 18 | "extra": { 19 | "laravel": { 20 | "providers": [ 21 | "Iinmass\\LaravelPackageChecker\\Providers\\PackageCheckerServiceProvider" 22 | ] 23 | } 24 | }, 25 | "version": "2.1.1", 26 | "authors": [ 27 | { 28 | "name": "iinmass", 29 | "email": "inmass.idbel@gmail.com", 30 | "role": "Developer" 31 | } 32 | ], 33 | "minimum-stability": "stable", 34 | "require": { 35 | "php": "^8.0", 36 | "illuminate/support": "^9.0|^10.0", 37 | "laravel/framework": "9.*|10.*", 38 | "guzzlehttp/guzzle": "^7.0" 39 | }, 40 | "require-dev": { 41 | "phpunit/phpunit": "^9.0", 42 | "vimeo/psalm": "^4.30" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Providers/PackageCheckerServiceProvider.php: -------------------------------------------------------------------------------- 1 | bind('laravel-package-checker', function () { 19 | return new \Iinmass\LaravelPackageChecker\Http\Services\PackageCheckerService(); 20 | }); 21 | } 22 | 23 | 24 | public function boot() 25 | { 26 | if ($this->app->runningInConsole()) { 27 | $this->setPublishers(); 28 | } 29 | 30 | $this->loadConfig(); 31 | $this->loadRoutes(); 32 | $this->loadViews(); 33 | 34 | } 35 | 36 | public function setPublishers() 37 | { 38 | $this->publishes([ 39 | __DIR__ . '/../config/package-checker.php' => config_path('package-checker.php') 40 | ], 'package-checker-config'); 41 | } 42 | 43 | /** 44 | * Group the routes and set up configurations to load them. 45 | * 46 | * @return void 47 | */ 48 | protected function loadRoutes() 49 | { 50 | Route::group($this->routesConfigurations(), function () { 51 | $this->loadRoutesFrom(__DIR__.'/../routes/web.php'); 52 | }); 53 | } 54 | 55 | /** 56 | * Routes configurations. 57 | * 58 | * @return array 59 | */ 60 | private function routesConfigurations() 61 | { 62 | return [ 63 | 'prefix' => config('package-checker.routes.prefix'), 64 | 'middleware' => config('package-checker.routes.middleware'), 65 | 'namespace' => config('package-checker.routes.namespace'), 66 | ]; 67 | } 68 | 69 | /** 70 | * Load views. 71 | * 72 | * @return void 73 | */ 74 | protected function loadViews() 75 | { 76 | $this->loadViewsFrom(__DIR__.'/../resources/views', 'package-checker'); 77 | } 78 | 79 | /** 80 | * Load config. 81 | * 82 | * @return array 83 | */ 84 | protected function loadConfig() 85 | { 86 | $this->mergeConfigFrom( 87 | __DIR__.'/../config/package-checker.php', 'package-checker' 88 | ); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/Http/Controllers/PackageCheckerController.php: -------------------------------------------------------------------------------- 1 | json($installedPackages); 19 | } 20 | 21 | public function getPackageDetails() 22 | { 23 | $data = [ 24 | 'name' => request('name'), 25 | 'version' => request('version'), 26 | ]; 27 | 28 | $requirements = PackageChecker::getPackageDetailsFor($data); 29 | return response()->json($requirements); 30 | } 31 | 32 | public function getLatestVersion() 33 | { 34 | $name = request('name'); 35 | $latestVersion = PackageChecker::getLatestVersion($name); 36 | return response()->json($latestVersion); 37 | } 38 | 39 | public function getPackageSize() 40 | { 41 | $name = request('name'); 42 | $requirements = request('requirements') ?? []; 43 | if (!$name) { 44 | return response()->json(['error' => 'Invalid request']); 45 | } 46 | $packageSize = PackageChecker::getPackageSize($name, $requirements); 47 | return response()->json($packageSize); 48 | } 49 | 50 | public function getVendorSize() 51 | { 52 | $vendorSize = PackageChecker::getAllPackageSizes(); 53 | $headOfResponse = []; 54 | $index = 0; 55 | foreach ($vendorSize as $package) { 56 | $headOfResponse[] = [ 57 | 'id' => 'ID_' . $index, 58 | 'name' => '', 59 | 'color' => '#' . substr(md5(rand()), 0, 6) 60 | ]; 61 | $index++; 62 | } 63 | $vendorSize = collect($vendorSize)->map(function ($item, $key) { 64 | return [ 65 | 'name' => $item['name'], 66 | 'parent' => 'ID_' . $key, 67 | 'value' => (int)$item['size'], 68 | ]; 69 | }); 70 | $vendorSize = array_merge($headOfResponse, $vendorSize->toArray()); 71 | return response()->json($vendorSize); 72 | } 73 | } -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | [](https://github.com/inmass/laravel-package-checker/blob/main/LICENSE) 2 | [](https://packagist.org/packages/iinmass/laravel-package-checker) 3 | 4 | 5 | ## Features 6 | 7 | Retrieves a list of packages required in your project's composer.json file. 8 | Displays the current version, latest version, installation status, and size for each package. 9 | Offers a treemap visualization of the vendor directory, showing the size distribution of packages. 10 | Helps optimize project dependencies by highlighting large packages. 11 | Easy installation and seamless integration with your existing project. 12 | 13 | ## Description 14 | 15 | Package Checker is a powerful tool that provides insights into the packages used in your project. It helps you manage your project's dependencies, keeping you informed about the current and latest versions of each package, their installation status, and their sizes. The package also offers a treemap visualization that displays the size distribution of packages within your vendor directory, allowing you to identify large packages that might require optimization. 16 | 17 | ## Installation 18 | 19 | The Laravel Package Checker can be easily installed via Composer. Run the following command in your terminal: 20 | 21 | ```bash 22 | composer require iinmass/laravel-package-checker 23 | ``` 24 | 25 | After the installation is complete, the package will be ready to use in your Laravel project. 26 | 27 | ## Usage 28 | 29 | To access the Package Checker, navigate to the following URL in your web browser: `http://your-app-url/package-checker/list`. 30 | This page provides a comprehensive overview of your Laravel project's packages, including the required packages from composer.json, their versions, installation status, and sizes as well as the tree of all the packages and their dependencies. 31 | 32 | ## Configuration 33 | 34 | The Laravel Package Checker requires no additional configuration. It seamlessly integrates with your Laravel project and retrieves the necessary information from the composer.json file and vendor directory. 35 | 36 | Alternatively, you can publish the package's configuration file and customize it to suit your needs by running the following command in your terminal: 37 | ```bash 38 | php artisan vendor:publish --tag=package-checker-config 39 | ``` 40 | 41 | ## Contributing 42 | 43 | Contributions to the Laravel Package Checker are welcome! If you would like to contribute to the project, please follow these steps: 44 | 45 | 1. Fork the repository. 46 | 2. Create a new branch for your feature or fix. 47 | 3. Make the necessary modifications. 48 | 4. Commit your changes. 49 | 5. Push the branch to your fork. 50 | 6. Submit a pull request. 51 | Please ensure that your code adheres to the project's coding standards and includes appropriate tests. 52 | 53 | ## License 54 | 55 | The Laravel Package Checker is open-source software licensed under the [MIT license](https://opensource.org/licenses/MIT). 56 | 57 | ## Credits 58 | 59 | The Laravel Package Checker is developed and maintained by [inmass](https://github.com/inmass) 60 | 61 | ## Support 62 | 63 | If you encounter any issues or have any questions, please create a new issue on the [issue tracker](https://github.com/inmass/laravel-package-checker/issues). I will be happy to assist you. -------------------------------------------------------------------------------- /src/resources/views/list.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 |You can also see every installed package on your vendor from the chart below.
17 | 18 |Package Statuses:
20 | Good 21 | Old 22 | Very Old 23 || Package Name | 29 |Package Requirements | 30 |Version | 31 |Latest Version | 32 |Status | 33 |Release Date | 34 |Size | 35 |
|---|---|---|---|---|---|---|
| 40 | 41 | Loading... 42 | | 43 |||||||