Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Easy Admin File Size Field Bundle Laravel Package

tourze/easy-admin-file-size-field-bundle

A Symfony bundle that adds a file size field type to EasyAdmin, letting you display and edit file sizes cleanly in admin forms and CRUD pages with consistent formatting and simple integration.

View on GitHub
Deep Wiki
Context7

Getting Started

This bundle adds a file-size field type to Tourze EasyAdmin, so a raw byte count stored on an entity (e.g. size on a Media/Document/Attachment model) can be displayed as a human-readable value (1.4 MB) and, where supported, edited or validated in forms.

  1. Install via Composer and let Symfony Flex/the bundle auto-register (check config/bundles.php if it doesn't appear):
    composer require tourze/easy-admin-file-size-field-bundle:^1.0
    
  2. Look first at the bundle's src/ for the field class (typically a Field/FieldConfigurator/FieldFactory implementation) and any templates/ directory — that tells you the exact option names before you write config.
  3. First use case: on an admin CRUD controller, add the field to configureFields() for the index/detail pages instead of the raw IntegerField, so operators stop reading 10485760 and start reading 10 MB.

Because 1.0.0 is the first stable tag after 0.0.3, treat the published API as now-frozen but verify the actual class names and option signatures in the repo before wiring them in — the release notes only contain a diff link.

Implementation Patterns

  • Display-only on lists, raw on forms. Use the file-size field on index/detail pages and keep the underlying numeric field (or a hidden input) on new/edit so the stored value stays a byte integer.
  • Format at the edge, not in the entity. Keep $file->getSize() returning bytes and let the field handle unit selection; this keeps sorting, filtering and API output correct.
  • Pair with an upload field. The natural composition is FileField (upload) + this field (size display). Compute size on persist ($file->setSize(filesize($path))) rather than trusting the client.
  • Column alignment/sorting. If the bundle exposes a sortable column, sort on the raw size column and only render the formatted string — otherwise "9 MB" sorts after "10 MB".
  • Reuse across resources. If several entities carry a size column, register the field once and reference it by name across CRUD controllers instead of repeating option arrays.
  • Version pinning. With 1.0.0 freshly cut, pin ^1.0 in composer.json and commit the lockfile so a later 1.x patch can't silently change formatting output in admin screenshots/tests.

Gotchas and Tips

  • 0.x → 1.0.0 is a stability signal, not a feature list. The release notes are only a compare link; read git diff 0.0.3..1.0.0 for renamed options or changed constructor signatures before upgrading. Anything public in 0.0.3 may have shifted.
  • Binary vs decimal units. Confirm whether the formatter uses 1024 (KiB/MiB, matching filesize() conventions) or 1000. A mismatch with what your storage layer or OS reports will produce "wrong" sizes in admin and erode trust in the tool.
  • Null, zero and negative values. 0 bytes and null (unpersisted upload) often render as 0 B or throw; decide explicitly and override the template if the default is unhelpful.
  • Large files / integer width. Byte counts above 2 GB exceed 32-bit ints; ensure the DB column is BIGINT and the field casts to int/float rather than string-mathing.
  • Locale and decimals. Number formatting may follow the request locale (1,4 MB vs 1.4 MB), which breaks copy-pasted values and snapshot tests. Check for a decimals/locale option.
  • Template overrides. If the rendering isn't what you need, override the bundle template in templates/bundles/... rather than editing vendor/ — but re-check after each 1.x bump, since template block names are a common breaking point.
  • Debugging tip. If the field renders empty, dump the raw entity value first: an empty string or a string-cast byte count is the usual culprit, not the field itself.
  • Extension points. Look for a formatter/unit-converter service you can decorate — swapping the formatting strategy via the container is cleaner than forking the field class.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast