Skip to content

A powerful Laravel Artisan command for cleaning and optimizing your Laravel application with beautiful, informative console output.

License

Notifications You must be signed in to change notification settings

ez-it-solutions/app-cleanup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Laravel App Cleanup Command

Ez IT Solutions

A powerful Laravel Artisan command for cleaning and optimizing your Laravel application with beautiful, informative console output.

πŸ“‹ Overview

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.

Command Output Example

✨ Features

  • 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

πŸš€ Installation

Option 1: Install via Composer (Recommended)

composer require ez-it-solutions/app-cleanup

That's it! The package will automatically register the command with Laravel.

Compatibility

This package is compatible with Laravel 6.x, 7.x, 8.x, 9.x, and 10.x.

Option 2: Manual Installation

  1. Download the AppCleanup.php file from our GitHub repository
  2. Place it in your Laravel project at app/Console/Commands/AppCleanup.php
  3. Laravel's auto-discovery should automatically register the command

πŸ“¦ Creating Your Own Package

If you want to create your own version of this package, follow these steps:

1. Set Up Package Structure

Create the following directory structure:

app-cleanup/
β”œβ”€β”€ src/
β”‚   └── Commands/
β”‚       └── AppCleanup.php
β”œβ”€β”€ composer.json
β”œβ”€β”€ LICENSE
└── README.md

2. Create composer.json

{
    "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
}

3. Create Service Provider

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()
    {
        //
    }
}

4. Update Namespace in Command

Update the namespace in your AppCleanup.php file to match your package:

namespace Ez_IT_Solutions\AppCleanup\Commands;

5. Publish to GitHub

# 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

6. Register with Packagist

  1. Visit Packagist
  2. Submit your GitHub repository URL: https://github.com/ez-it-solutions/app-cleanup
  3. Once approved, your package will be available via Composer

7. Set Up GitHub Webhooks for Packagist

To automatically update your package on Packagist when you push to GitHub:

  1. Go to your GitHub repository settings
  2. Click on "Webhooks" > "Add webhook"
  3. Set Payload URL to: https://packagist.org/api/github?username=your-packagist-username
  4. Set Content type to: application/json
  5. Select "Just the push event"
  6. Click "Add webhook"

8. Add GitHub Actions for Testing (Optional)

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

πŸ“ Usage

Basic Usage

php artisan app:cleanup

This will prompt for confirmation before running the cleanup process.

Skip Confirmation

php artisan app:cleanup --force

This will run the cleanup process without asking for confirmation.

πŸ”§ Customization

Adding or Removing Commands

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
];

Customizing the Output

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('β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•');

Changing the Command Name

If you want to change the command name, modify the $signature property:

protected $signature = 'your:command-name {--force : Force the operation without confirmation}';

πŸ“Š Output Example

╔═════════════════════════════════════════════════╗
β•‘                                                 β•‘
β•‘         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                 β•‘
β•‘                                                 β•‘
β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•

🀝 Contributing

Contributions are welcome! Feel free to submit a pull request or open an issue.

πŸ“„ License

This project is open-sourced software licensed under the MIT license.

πŸ‘¨β€πŸ’» Author

Ez IT Solutions
https://github.com/ez-it-solutions


Made with ❀️ by Ez IT Solutions

About

A powerful Laravel Artisan command for cleaning and optimizing your Laravel application with beautiful, informative console output.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages