Download the PHP package daikazu/asset-cleaner without Composer

On this page you can find all versions of the php package daikazu/asset-cleaner. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package asset-cleaner

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Laravel Asset Cleaner

This package helps you clean up your Laravel app in development by tracking down unused image files and Blade components. It scans through your codebase, finds where assets are referenced, and flags any leftover files that have no connection to the app so you can safely remove the clutter and keep things tidy.

Features

Image Asset Cleaner

Blade Component Cleaner

Installation

Install the package via Composer:

Publish the config file:

Quick Start

Image Asset Cleaner

Step 1: Scan for unused assets

This scans your project and generates an unused-assets.json manifest in your project root.

Step 2: Review the manifest

Open unused-assets.json and review the list of unused assets. Remove any entries for files you want to keep.

Step 3: Clean up

This deletes the files listed in the manifest (with backup by default).

Blade Component Cleaner

Step 1: Scan for unused components

This scans your project for Blade components and generates an unused-components.json manifest.

Step 2: Review the manifest

Open unused-components.json and review the list of unused components. Remove any entries for components you want to keep.

Step 3: Clean up

This deletes the components listed in the manifest. For class-based components, both the PHP class and the Blade view are deleted.

Commands

Image Asset Commands

asset-cleaner:scan

Scan for unused image assets and generate a manifest.

asset-cleaner:clean

Delete unused assets based on the manifest or perform a one-shot cleanup.

Blade Component Commands

blade-cleaner:scan

Scan for unused Blade components and generate a manifest.

blade-cleaner:clean

Delete unused components based on the manifest or perform a one-shot cleanup.

Configuration

Programmatic Usage

Image Asset Cleaner

Blade Component Cleaner

How It Works

Image Asset Detection

  1. Scanning: The package recursively scans configured directories for files matching image extensions.

  2. Reference Detection: For each image found, the package searches your codebase for references using multiple strategies:

    • Full relative path (public/images/hero.jpg)
    • Path without public/ prefix (images/hero.jpg)
    • Filename only (hero.jpg)
    • Filename without extension (hero)
  3. Manifest Generation: Unused assets are written to a JSON manifest that you can review and edit.

  4. Deletion: Files are deleted based on the manifest, with optional backup to .asset-cleaner-backup/.

Blade Component Detection

  1. Scanning: The package scans for:

    • Anonymous components in resources/views/components/
    • Class-based components in app/View/Components/
  2. Component Name Derivation:

    • Anonymous: resources/views/components/forms/input.blade.php → forms.input → <x-forms.input>
    • Class-based: App\View\Components\Forms\TextInput → forms.text-input → <x-forms.text-input>
  3. Reference Detection: For each component, the package searches for:

    • Component tags: <x-component-name>, <x-component-name />
    • Nested components: <x-forms.input>
    • Dynamic components: <x-dynamic-component component="name">
    • Legacy directive: @component('components.name')
    • Direct view calls: view('components.name')
    • Class registrations: Blade::component()
  4. Deletion: For class-based components, both the PHP class and Blade view are deleted together.

Best Practices

  1. Always review the manifest before running clean, especially the first time.

  2. Use --dry-run to preview changes before committing to deletion.

  3. Keep backups enabled until you're confident in the results.

  4. Add to .gitignore:

  5. Protect critical assets by adding patterns to protected_patterns in the config.

  6. Run after major refactors when you've removed features or redesigned pages.

  7. Protect layout components - they may not appear to be used if they're only referenced via @extends.

Limitations

Image Assets

Blade Components

For dynamic references, add the pattern to protected_patterns or remove entries from the manifest before cleaning.

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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


All versions of asset-cleaner with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^11.0||^12.0||^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package daikazu/asset-cleaner contains the following files

Loading the files please wait ...