Download the PHP package keyagency/statamic-asset-usage without Composer

On this page you can find all versions of the php package keyagency/statamic-asset-usage. 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 statamic-asset-usage

Asset Usage

Statamic Marketplace Latest Version Tests

See where every asset is used, and find the ones that aren't used at all.

A Statamic 6 Control Panel addon for cleaning up your asset containers. It shows you where an asset is used, so you can delete the files nothing needs without guessing.

Works on flat-file and database sites alike

Content is read exclusively through Statamic's repositories (Entry::query(), Term::query(), GlobalSet::all(), …), never by scanning the content/ directory. So on a site using the eloquent driver, where entries live in the database rather than on disk, everything is found just the same. And rather than only telling you whether an asset is used, it tells you where.

Installation

The second command builds the usage index. After that the addon keeps itself up to date as you edit content.

What counts as "used"

Every reference format Statamic itself understands, found anywhere in your content, at the top level or nested inside Grid, Replicator, Group and Bard sets:

Where What it looks like
Asset / file fields img/photo.jpg (a path relative to the container)
Link fields, Bard images, Bard link marks asset::main::img/photo.jpg
Markdown and Bard HTML statamic://asset::main::img/photo.jpg
Any text, textarea, markdown or HTML field /assets/img/photo.jpg, https://example.com/assets/img/photo.jpg

That last row is off in Statamic's own reference tracking but on by default here (scan_urls), because a hand-typed URL is exactly the case where you'd otherwise delete a file that was in use.

Scanned content types: entries (including unpublished working copies), global sets, taxonomy terms, navigations, users, other assets' own fields, and form submissions.

An asset can also be referenced without ever being saved onto a single item, so these are scanned too:

Where What it covers
Collection and taxonomy cascades The inject values that fall through to every entry or term, where an addon such as an SEO one keeps its per-section defaults
Addon settings What addons save in resources/addons/{slug}.yaml, which is where a site-wide default image usually lives
Blueprint and fieldset defaults A field's default holds an asset until something is saved over it, and on a field nobody touches it holds it for good

scanned_types is the complete set, so listing only the types you want is enough. Anything left out is off. That also means a config you published before a type existed would leave that type switched off, so updates add new keys to your published config for you. php please asset-usage:doctor names any your config is still missing.

What it doesn't see

Where the column appears

The column arrives through the container's blueprint, and Statamic renders blueprint columns before its own File / Size / Last Modified, and there's no hook to change that. If you'd rather have it at the end, use Customize Columns in the browser and drag it there; Statamic remembers the order per user.

The column deliberately shows only a tick or a cross. A count or a list of sites made rows wide enough to push the filename off screen; the numbers live in the editor panel and on the Tools page.

Multisite

Every usage records the site of the item it was found in, so an asset used only in your Dutch entries shows Nederlands and nothing else. An asset counts as unused only when no site uses it. Items that have no site of their own (users, other assets, form submissions) are grouped under "All sites".

The index

Scanning a whole site per page load isn't viable, so usage lives in an index at storage/statamic/asset-usage/index.json. It is:

Which assets exist is read through the container's asset query, the same source the asset browser uses, not through the container's file listing, which on the eloquent driver reports the container root only.

The incremental updates run through a queued listener (like Statamic's own reference updating). On the sync queue that means inline; with a real queue connection you need a worker running, or set auto_update to false and rebuild on a schedule instead.

Commands

--delete refuses to run against an out-of-date index, and re-checks every asset immediately before removing it.

asset-usage:doctor is for when the numbers look wrong. Per container it prints what the filesystem holds (split into root and subfolders), what the asset query finds, what Statamic's own file listing reports, how many paths resolve to an actual asset and how many are recorded as used. It also flags files that exist on disk but aren't known as assets: on the eloquent driver those have no row in the assets table, so nothing can report on them until php please eloquent:import-assets brings them in.

Above the per-container output it lists the content types actually being scanned, and warns about any that your published config doesn't mention, because those are switched off, which is the usual reason a whole class of references seems to go unnoticed.

Deleting

Deleting is available from the Tools page (per row, for a checkbox selection, and as Delete all unused, which covers every unused asset the active filters match rather than only the page you're looking at, up to 500 per click, so a big cleanup takes a few) and from the CLI. Everything goes through the same rails:

Configuration

Permissions

The "Used in" panel and the browser column follow Statamic's normal asset permissions; if you can see the asset, you can see its usage. The Tools page does the same: it only lists containers whose assets the user may view, and deleting also needs Statamic's own delete permission for that container.

Support

Found a bug or missing a feature? Open an issue on GitHub. CONTRIBUTING.md lists what to include, such as your Statamic and PHP versions, whether the site uses the Eloquent driver, and the output of php please asset-usage:doctor.

License

Proprietary. © Key Agency.


All versions of statamic-asset-usage with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
pixelfear/composer-dist-plugin Version ^0.1.6
statamic/cms Version ^6.0
dompdf/dompdf Version ^3.1.6
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 keyagency/statamic-asset-usage contains the following files

Loading the files please wait ...