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
Data Layer Bundle

Data Layer Bundle Laravel Package

lexik/data-layer-bundle

Lexik DataLayerBundle provides a flexible data layer abstraction for Symfony applications, letting you organize and query business data through configurable layers. Lightweight, easy to integrate, and maintained by Lexik.

View on GitHub
Deep Wiki
Context7

Manipulate the Google Tag Manager Data Layer from your Symfony application

Frequently asked questions about Data Layer Bundle
Is lexik/data-layer-bundle compatible with Laravel?
No. It is a Symfony bundle built around a Symfony Bundle class, DI compiler pass, and Twig extension, and it ships no Laravel service provider, facade, or Blade integration. Installing it in a Laravel app adds Symfony and Twig constraints without providing usable Laravel hooks. The portable part is the pattern: a request-scoped PHP accumulator rendered before the GTM snippet, which is roughly 100–200 lines to reimplement natively.
Can I install lexik/data-layer-bundle in Laravel 10 or 11?
Realistically no. The package targets the Symfony 2.8/3.x era with PHP 7.x constraints, while Laravel 10 and 11 require PHP 8.1+ and modern Symfony components. Composer will either fail dependency resolution or force downgrades across your framework. Do not plan an integration around it.
How do I install and configure lexik/data-layer-bundle?
For Symfony, you would require lexik/data-layer-bundle, register the bundle in AppKernel, configure layers, and use the Twig extension to render the data layer JSON. For Laravel there is no install path: no config publishing, no service provider, and no Blade directive. The bundle's configuration schema and Twig API would need to be reimplemented as Laravel config and a Blade component.
What Laravel and PHP versions does lexik/data-layer-bundle support?
None for Laravel. The last release, v1.1.1 from February 2018, targets Symfony 2.8/3.x and PHP 7.x, with no PHP 8 support or Laravel compatibility work. Modern Laravel 10 and 11 apps on PHP 8.1+ should assume it will not install cleanly.
How do I push Google Tag Manager dataLayer events from Laravel?
Do not use this bundle to do it. Build a small request-scoped service that accumulates key/value payloads and events, expose it through a Blade component or directive, and render a JSON array before the GTM container snippet. That keeps the data layer server-side, testable, and free of an abandoned Symfony dependency.
Is lexik/data-layer-bundle still maintained?
No. The last release is v1.1.1 from February 2018, the repository has about 14 stars and zero dependents, and there have been no compatibility or security releases since. That means no PHP 8 validation and no real-world consumer feedback. Treat it as a reference implementation, not a maintained dependency.
Does lexik/data-layer-bundle handle XSS and JSON escaping safely?
The bundle renders data layer values as JSON into Twig templates, typically inside a script context. The technical evaluation flags safe JSON escaping inside script tags and non-UTF-8 payload handling as unverified, so you should not assume those risks are covered. If you reimplement in Laravel, use json_encode with appropriate flags, escape closing script sequences, and filter PII before rendering.
Does lexik/data-layer-bundle support GA4 ecommerce and consent mode?
No GA4 ecommerce item schema support is documented, and the package has no notion of consent-mode gating. It is a generic data layer accumulator from 2018, predating GA4 and modern consent requirements. In a Laravel reimplementation, model ecommerce items explicitly and gate pushes behind your consent service.
How should I test a GTM data layer integration in Laravel?
Test the service that builds the array, not the GTM container: assert keys, event names, ecommerce item shapes, and that PII is excluded. Then render the Blade component in a feature test and assert the JSON is valid and safely escaped for a script context. Keep a contract test for the expected window.dataLayer.push payloads.
What are alternatives to lexik/data-layer-bundle for Laravel?
For Laravel, the best alternative is a native implementation: a singleton or scoped DataLayer service, a Blade component or directive, and a config entry for the GTM container ID. That avoids the abandoned Symfony bundle and its transitive constraints. If you want a package, look for a Laravel-specific GTM package with recent releases and PHP 8 support, but verify it handles consent and ecommerce schemas.
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.
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package