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

Media Api Bundle Laravel Package

saro0h/media-api-bundle

Symfony bundle that adds a REST API for media management, including upload, listing, retrieval, and deletion of media files and metadata. Configurable storage and Doctrine integration simplify adding media endpoints to your application.

View on GitHub
Deep Wiki
Context7

Getting Started

Note up front: despite the name pattern, this is a Symfony bundle (...Bundle, PSR-4 under Saro0h\MediaApiBundle), not a Laravel package. There is no service provider, no config/mediaapi.php, no publishable migrations. If you're a Laravel dev, mentally map the workflow to: install a Composer dep → register it in the kernel/bundles.php → configure → hit a route.

  1. Install:
    composer require saro0h/media-api-bundle
    
  2. Register the bundle:
    • Symfony 4+/5+/6+: add Saro0h\MediaApiBundle\MediaApiBundle::class => ['all' => true] to config/bundles.php.
    • Symfony 3: add new Saro0h\MediaApiBundle\MediaApiBundle() to AppKernel::registerBundles().
  3. Read src/Resources/config/routes.xml (or routing.yaml) first. With 12 stars and no docs, the routes file is the API surface. Look for the controller it points at and the HTTP verb/path (typically something like POST /api/media or /media/upload).
  4. Inspect the DependencyInjection/Configuration.php for the real config keys — this is where upload directory, allowed MIME types, and max size are usually defined.
  5. First use case: curl -F "[email protected]" http://localhost:8000/<route-from-routes.xml> and see if a 200 with a stored path/URL comes back. That round-trip tells you more than any README will.

Implementation Patterns

Consume the JSON endpoint from a client. If the bundle exposes a controller, the intended usage is a thin client: authenticate (whatever security is configured on that route), multipart/form-data POST, parse the JSON response ({ "url": ..., "id": ... } or similar). Don't reinvent it — the whole value is the ready-made endpoint.

Call the underlying service from your own controllers. The most robust pattern with an unmaintained bundle is to bypass its routing and inject the uploader service directly:

public function upload(Request $request, MediaUploader $uploader)
{
    $file = $request->files->get('file');
    $media = $uploader->upload($file); // method name: check the interface
    return $this->json(['id' => $media->getId(), 'url' => $media->getUrl()]);
}

This gives you full control over validation, response shape, and security without fighting the bundle's conventions.

Wire into a form + entity flow. Typical pattern: form submits a FileType, controller passes the uploaded file to the bundle's service, stores the returned path/ID on your entity ($post->setImage($media->getUrl())), and the bundle owns the filesystem concern. This separation is the reason to keep it rather than roll your own.

Configure storage via bundle config. Set the upload directory and allowed MIME list in config/packages/media_api.yaml, then reference the same directory elsewhere (VichUploader, LiipImagine, etc.) so you have one source of truth for where uploaded files land.

Guard the route. Add security.yaml access control or a firewall rule for the upload path — a file-upload endpoint with no auth is a classic abuse vector.

Gotchas and Tips

  • Abandonment risk is the headline. 12 stars, 0 dependents, score 0.12 — treat this as a "read the source, vendor the logic" package. Likely targets old Symfony (2/3/4) and PHP 7. Expect composer require to fail on Symfony 6/7 due to version constraints; if so, either --ignore-platform-reqs (dangerous) or copy the 2–3 relevant classes into your app. With this little code, inlining it is often cleaner than depending on it.
  • No migrations, no auto-table. If the bundle persists a Media/File entity, you must run its migration or map the entity yourself. Grep for @ORM\Entity and Resources/config/doctrine/.
  • The upload directory is probably not created for you. Check whether the config path is created mkdir -p-style; if not, your first upload throws a FileException that looks like a permissions bug but is a missing-directory bug.
  • MIME validation lives in the bundle, not the browser. Symfony's File::getMimeType() uses finfo; extension checks alone are insufficient. If the bundle only checks extensions, add a File constraint with mimeTypes in your own controller as a belt-and-braces guard.
  • Debug route registration with bin/console debug:router | grep -i media — faster than reading YAML and tells you the actual generated route name and path.
  • Extension point: if you need to customize storage (S3, Flysystem), look for an interface the bundle type-hints (e.g. UploaderInterface, StorageInterface). Override the service alias in your services.yaml rather than forking the bundle. If no interface exists, that's your signal to stop using the bundle and wire it manually.
  • No tests, no CI badge = assume untested on your stack. Smoke-test upload, upload with oversized file, and upload with a .php masquerading as .jpg before shipping.
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.
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle
adachsoft/api-version-bundle
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
cgv/localized-resource