A powerful Laravel Artisan command for cleaning and optimizing your Laravel application with beautiful, informative console output.
The app:cleanup
command provides a comprehensive solution for clearing various Laravel caches and optimizing your application. It runs multiple optimization commands in sequence with visual feedback, progress tracking, and detailed execution statistics.
- Beautiful Console Output: Colorful, well-formatted console output with progress bars
- Multiple Cache Clearing Operations: Clears route, config, application, view, and event caches
- Performance Optimization: Rebuilds caches and optimizes the application
- Execution Tracking: Shows execution time for each command and total execution time
composer require ez-it-solutions/app-cleanup
That's it! The package will automatically register the command with Laravel.
This package is compatible with Laravel 6.x, 7.x, 8.x, 9.x, and 10.x.
- Download the
AppCleanup.php
file from our GitHub repository - Place it in your Laravel project at
app/Console/Commands/AppCleanup.php
- Laravel's auto-discovery should automatically register the command
If you want to create your own version of this package, follow these steps:
Create the following directory structure:
app-cleanup/
βββ src/
β βββ Commands/
β βββ AppCleanup.php
βββ composer.json
βββ LICENSE
βββ README.md
{
"name": "ez-it-solutions/app-cleanup",
"description": "A beautiful Laravel command for cleaning and optimizing your application",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Ez IT Solutions",
"email": "[email protected]"
}
],
"require": {
"php": "^7.3|^8.0"
},
"require-dev": {
"laravel/framework": "^6.0|^7.0|^8.0|^9.0|^10.0"
},
"autoload": {
"psr-4": {
"Ez_IT_Solutions\\AppCleanup\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"Ez_IT_Solutions\\AppCleanup\\AppCleanupServiceProvider"
]
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
Create a file at src/AppCleanupServiceProvider.php
:
<?php
namespace Ez_IT_Solutions\AppCleanup;
use Illuminate\Support\ServiceProvider;
use Ez_IT_Solutions\AppCleanup\Commands\AppCleanup;
class AppCleanupServiceProvider extends ServiceProvider
{
public function boot()
{
if ($this->app->runningInConsole()) {
$this->commands([
AppCleanup::class,
]);
}
}
public function register()
{
//
}
}
Update the namespace in your AppCleanup.php
file to match your package:
namespace Ez_IT_Solutions\AppCleanup\Commands;
# Initialize Git repository
git init
# Add all files
git add .
# Commit the files
git commit -m "Initial commit"
# Create a new repository on GitHub at https://github.com/ez-it-solutions/app-cleanup
# Then push to GitHub
git remote add origin https://github.com/ez-it-solutions/app-cleanup.git
git branch -M main
git push -u origin main
# Tag a release
git tag -a v1.0.0 -m "Initial release"
git push origin v1.0.0
- Visit Packagist
- Submit your GitHub repository URL:
https://github.com/ez-it-solutions/app-cleanup
- Once approved, your package will be available via Composer
To automatically update your package on Packagist when you push to GitHub:
- Go to your GitHub repository settings
- Click on "Webhooks" > "Add webhook"
- Set Payload URL to:
https://packagist.org/api/github?username=your-packagist-username
- Set Content type to:
application/json
- Select "Just the push event"
- Click "Add webhook"
Create a file at .github/workflows/tests.yml
:
name: Tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
php: [7.4, 8.0, 8.1, 8.2]
laravel: [8.*, 9.*, 10.*]
exclude:
- php: 7.4
laravel: 10.*
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip
coverage: none
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
composer update --prefer-dist --no-interaction --no-progress
php artisan app:cleanup
This will prompt for confirmation before running the cleanup process.
php artisan app:cleanup --force
This will run the cleanup process without asking for confirmation.
You can easily customize which commands are run by modifying the $commands
array in the handle()
method:
$commands = [
'Clear Route Cache' => 'route:clear',
'Clear Configuration Cache' => 'config:clear',
// Add or remove commands here
];
You can customize the header and footer boxes by modifying the strings in the handle()
method:
$this->info('βββββββββββββββββββββββββββββββββββββββββββββββββββ');
$this->info('β β');
$this->info('β YOUR CUSTOM HEADER HERE β');
$this->info('β β');
$this->info('βββββββββββββββββββββββββββββββββββββββββββββββββββ');
If you want to change the command name, modify the $signature
property:
protected $signature = 'your:command-name {--force : Force the operation without confirmation}';
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β APPLICATION CLEANUP β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
[1/10] Running: Clear Route Cache (route:clear)
100% [============================] β Done
Time: 0.61s
[2/10] Running: Clear Configuration Cache (config:clear)
100% [============================] β Done
Time: 0.62s
...
Command Execution Summary:
+------+----------------+-----------------------------+--------------+---------+
| Step | Command | Description | Duration (s) | Status |
+------+----------------+-----------------------------+--------------+---------+
| 1 | route:clear | Clear Route Cache | 0.61 | Success |
| 2 | config:clear | Clear Configuration Cache | 0.62 | Success |
| ... | ... | ... | ... | ... |
+------+----------------+-----------------------------+--------------+---------+
Total execution time: 10.53 seconds
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β CLEANUP COMPLETED SUCCESSFULLY β
β β
β YOUR COMPANY Β© 2025 β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
Contributions are welcome! Feel free to submit a pull request or open an issue.
This project is open-sourced software licensed under the MIT license.
Ez IT Solutions
https://github.com/ez-it-solutions
Made with β€οΈ by Ez IT Solutions