Weave Code
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

Config To Js Bundle Laravel Package

dawen/config-to-js-bundle

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Frontend-Backend Decoupling: Enables server-side configuration management for JavaScript applications, reducing hardcoded values in frontend code and simplifying environment-specific settings (e.g., API endpoints, feature flags).
  • Build vs. Buy: Justifies buying this lightweight package over custom development for teams needing a simple, Laravel-native solution to inject PHP configs into JS bundles (vs. manual scripts or complex tooling like Webpack plugins).
  • Roadmap for Progressive Enhancement: Supports a phased migration strategy—start with critical configs (e.g., imageLocation, appVersion) and expand to dynamic features (e.g., A/B testing flags, localization strings) without frontend rebuilds.
  • Performance Optimization: Reduces bundle size by externalizing configs to a separate JS file, enabling lazy-loading or conditional inclusion based on runtime needs.
  • Multi-Environment Support: Centralizes environment-specific configs (dev/staging/prod) in Laravel’s config/ directory, auto-generated into JS at build time, reducing deployment errors.

When to Consider This Package

  • Adopt if:

    • Your Laravel app serves JS assets (e.g., SPAs, single-page apps) and needs to inject PHP configs into the frontend without manual file management.
    • You prioritize simplicity over flexibility—this is a single-purpose tool for static config dumping (not dynamic runtime updates).
    • Your team lacks frontend build tooling (e.g., Webpack) or wants to avoid adding complexity for basic config injection.
    • You’re using Symfony’s AppKernel and can integrate bundles (targets Laravel 4/5; may require adaptation for newer versions).
  • Look elsewhere if:

    • You need dynamic config updates (e.g., real-time feature toggles)—consider WebSocket-based solutions or frontend state management.
    • Your JS app uses advanced bundlers (Webpack, Vite) with built-in config injection (e.g., DefinePlugin).
    • You require type safety or validation for configs—this package outputs raw JS objects without schema enforcement.
    • Your Laravel version is not bundle-compatible (e.g., Laravel 8+ with PSR-4 autoloading; may need composer patching).
    • You need multi-language/i18n support—this is limited to simple key-value pairs.

How to Pitch It (Stakeholders)

For Executives: *"This package lets us centralize frontend configurations (like API endpoints or app versions) in Laravel’s PHP config files, then auto-generate a JS file at build time. It’s a lightweight, zero-maintenance way to:

  • Reduce deployment errors by eliminating hardcoded frontend values.
  • Simplify environment management (e.g., switch API URLs without touching JS code).
  • Cut build complexity—no need for Webpack plugins or manual scripts. Cost: Near-zero (MIT license, 10-minute setup). Risk: Minimal (isolated to config dumping). ROI: Faster releases and fewer frontend bugs."*

For Engineering: *"This solves the ‘how do I get PHP configs into my JS app?’ problem with a Laravel-native solution:

  • Pros:
    • Zero runtime overhead (configs are baked into JS at build time).
    • Works with existing Laravel config system (e.g., config/services.php).
    • Outputs clean, minifiable JS (configurable output path).
  • Cons:
    • Not for dynamic updates (use a WebSocket service instead).
    • Limited to static configs (no runtime overrides).
  • Implementation:
    1. Add the bundle to composer.json and AppKernel.php.
    2. Define configs in config/packages/config_to_js.yml.
    3. Run php bin/console config:js:dump in your build pipeline.
    • Alternatives considered: Custom Artisan command (rejected for maintenance overhead) or Webpack DefinePlugin (rejected for Laravel integration). This is the simplest path for our stack."*
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.
craftcms/url-validator
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony