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

Php Vars To Js Bundle Laravel Package

hospect/php-vars-to-js-bundle

A Symfony bundle that passes PHP variables to JavaScript, letting you expose server-side data to frontend scripts in a simple, centralized way. It reduces boilerplate by keeping configuration and dynamic values in sync between PHP and JS.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. This is a thin Symfony2 bundle wrapping laracasts/PHP-Vars-To-Js-Transformer to expose server-side PHP values to client-side JavaScript — typically a Twig function that emits a window.* assignment or a <script> block. Two seams matter for architecture review:

  • The core transformer is Laravel-oriented and leans on Illuminate support primitives. Pulling those into a Symfony container imports a parallel framework's building blocks for what is fundamentally a JSON-serialization concern — a poor dependency-to-value ratio.
  • The bundle targets the legacy Symfony2 bundle system (*Bundle class, Resources/config/services.yml, manual AppKernel registration). It does not map to Symfony Flex recipes or modern autoconfiguration, so it is only "drop-in" for hosts already on Symfony 2.x/3.x. For a Laravel-primary team, the bundle is the wrong artifact entirely — the upstream laracasts/PHP-Vars-To-Js-Transformer package is the direct, first-class integration.

Integration feasibility. The functional surface is trivially small: one service, one Twig helper, one serialization contract. A competent developer reproduces the entire behavior as a ~100–150 line Twig extension plus a small serializer service. That caps integration cost, but it also caps the value of adopting the dependency — we would import an unmaintained package to avoid writing a day of code we would own outright.

Technical risk. Dominant and disqualifying in the default case:

  • Symfony 2.8 reached end of life in November 2018; the bundle's supported runtime is itself unsupported and ineligible for security patching.
  • 9 stars, 0 dependents, single maintainer, no visible CI, no test suite, no security policy. Package health score of 0.075 is consistent with an abandoned artifact.
  • No documented PHP version matrix; Illuminate and Twig constraints are likely to collide with anything modern.
  • License is permissive (MIT), which is fine, but permissiveness does not offset the absence of maintenance.

The 9.15 opportunity score reflects an uncontested niche, not a validated solution — it should not be read as a buy signal.

Key questions before any spend:

  1. Is the target application actually on Symfony 2.x/3.x, or are we retrofitting onto Symfony 5+/6+?
  2. Does the bundle emit inline <script> blocks, and is our Content-Security-Policy compatible (nonce, hash, or strict-dynamic)?
  3. How does it serialize non-scalars — JsonSerializable, Doctrine entities, closures, resources?
  4. Who owns the fork internally, and what is the SLA for compatibility fixes?
  5. Can we use the underlying Laravel package directly and skip the bundle entirely?

Integration Approach

Stack fit. Two distinct paths:

  • Laravel host: do not use this bundle. Require laracasts/PHP-Vars-To-Js-Transformer directly, publish its config, and use the Js::put() facade in controllers or view composers. This is the intended usage; risk is far lower and the escaping behavior is the same.
  • Symfony host: treat the bundle as a reference implementation, not a dependency. Read it, then write an internal JsViewData service plus Twig function backed by json_encode with JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_THROW_ON_ERROR, emitting into a namespaced global (e.g. window.__STATE__). Budget 1–2 days including tests.

Migration path (if the bundle must be adopted). Vendor it rather than depending on it:

  • Pin to a commit SHA, not a version range — there will be no releases.
  • Wrap the bundle's service behind an internal interface (JsViewDataProvider::class) so no application code references the third-party namespace.
  • Keep the wrapper at the outermost layer so a future replacement is a single container binding change.

Compatibility. Verify against the actual lockfile before committing:

  • PHP version floor and any strict_types gaps.
  • Symfony HttpKernel / DependencyInjection / TwigBundle constraint ranges.
  • Twig 1.x vs 3.x API drift (function registration signatures, escaping flags).
  • Illuminate component collisions if the app already pulls illuminate/support or similar.

Sequencing. A staged, time-boxed plan:

  1. Spike (0.5 day): install in a branch, wire into one controller and one template, confirm output shape and escaping behavior with hostile input (</script>, & " ').
  2. Proof (1 day): apply to a single real view; validate CSP, XSS posture, and payload size under realistic data.
  3. Abstraction (0.5 day): introduce the internal interface and route all call sites through it.
  4. Decision gate: adopt-as-vendored-fork vs. replace-with-internal-implementation. Default recommendation is replace; the wrapper makes that a low-cost call either way.

Operational Impact

Maintenance. Assume zero upstream activity. Budget a named internal owner and a recurring line item for PHP/Symfony upgrade compatibility audits. A vendored fork means every future framework bump triggers a manual review of a few hundred lines of third-party code — small, but permanently non-zero, and it scales poorly across teams if the pattern spreads.

Support. There is no community to escalate to and no maintainer response path. Support is entirely internal: whoever wrote the wrapper owns it. The behavior contract and escaping rules must be documented explicitly in a runbook, because the upstream code will not document them and future engineers will not discover them by reading a dead bundle.

Scaling. Runtime cost is negligible — per-request serialization of a small array. The scaling concern is payload, not throughput: injecting large datasets into inline HTML inflates every response and defeats HTTP caching for those pages. Keep injected values small (IDs, feature flags, user identity, i18n keys) and fetch bulk data through a cacheable JSON endpoint. If the payload is user-specific, ensure it is never served from a shared full-page cache.

Failure modes. These require explicit test coverage:

  • Serialization errors on Doctrine entities, closures, or resources producing a fatal or an empty object.
  • XSS via </script> in user-controlled values — confirm the emitter hex-escapes or uses a type="application/json" data island rather than raw interpolation.
  • CSP violations if inline scripts are blocked under a strict policy; may require a nonce or a shift to data attributes.
  • Stale or leaked values on cached pages — injected data is baked into HTML, so page caching can serve one user's variables to another.
  • Silent no-op if the bundle's DI extension fails to register and the Twig function resolves to nothing — the page renders with window.__STATE__ === undefined and downstream JS fails at runtime rather than at deploy time.

Ramp-up. Technical ramp-up is trivial — any developer familiar with Twig or Blade understands the pattern in under an hour. The real cost is institutional: onboarding engineers onto a dead Symfony2-era bundle with sparse documentation requires a written internal runbook and a named owner. That hidden organizational cost is the primary argument for the internal-implementation path.

Bottom line for a TPM: pattern-valid, package-rejected. On a Laravel stack, use laracasts/PHP-Vars-To-Js-Transformer directly and ignore this bundle. On a Symfony stack, spend the 1–2 days to implement the pattern internally behind a small service interface — the dependency buys almost nothing and imports end-of-life framework risk plus an unowned maintenance obligation.

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.
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin