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

Symfony Csp Bundle Laravel Package

opctim/symfony-csp-bundle

A Symfony bundle that simplifies adding Content-Security-Policy headers to responses. Configure directives, generate nonces and hashes for inline scripts/styles, and collect violation reports to help harden your app against XSS and other injection attacks.

View on GitHub
Deep Wiki
Context7

Getting Started

  • Confirm the runtime matrix before installing: 2.0 requires PHP 8.1+ and drops Symfony 5.4 support. If the app still resolves Symfony 5.4 components transitively, upgrade those dependencies first.
  • Install with an explicit major constraint: composer require vendor/package:^2.0. Use --with-all-dependencies if Composer reports conflicts from Symfony/Laravel constraints.
  • Look first at README.md, UPGRADE.md/CHANGELOG.md, the package composer.json, the service provider, and any publishable config file. These reveal required bindings, config keys, and extension points faster than browsing source.
  • If the package publishes config or migrations, run the documented publish command immediately, then inspect the generated config before changing values.
  • First use case: inject the package’s primary service into a controller, form request, job, or Artisan command and perform one operation end-to-end. Prefer constructor injection over resolving from the container inline.
  • Add one focused feature test using the package’s fake or test helper, if provided, so the first integration is verified without hitting external services.

Implementation Patterns

  • Bind package contracts to implementations in a service provider when the package exposes interfaces. Inject the interface into application code rather than the concrete class.
  • Keep package configuration in config/ and environment-specific values in .env. After changing env values, run php artisan config:clear locally and ensure deployment scripts rebuild config cache.
  • Wrap package calls in small application-level services when used in multiple places. This isolates the package API from controllers and jobs and makes future major upgrades cheaper.
  • For queued work, resolve the package service inside the job’s handle() method or inject it via the container; do not serialize the service itself. Pass IDs or scalar payloads between jobs.
  • Use Laravel events/listeners to react to package outcomes instead of embedding side effects in the call site. Register listeners in EventServiceProvider or via discovery.
  • In tests, use the package’s fake/assertion helpers where available. Otherwise bind a test double for the contract and assert interactions at the application boundary.
  • For the 2.0 upgrade, create a branch, update the constraint, run composer update vendor/package --with-all-dependencies, then run the full test suite, Larastan/PHPStan, and a smoke test of the main package workflow.
  • Maintain a CI matrix that tests the lowest and highest supported dependency sets. This is especially important because 2.0 spans dropped Symfony 5.4 support and newly added Symfony 8 support.
  • Treat Symfony 8 support as an opt-in path: verify the app’s PHP version and transitive Symfony constraints before allowing Composer to resolve the newest set.

Gotchas and Tips

  • PHP 8.1 is now the floor. Code using enums, readonly properties, or first-class callable syntax is expected; running 2.0 on PHP 8.0 will fail.
  • Dropping Symfony 5.4 is the main breaking change. Check with composer why symfony/* and composer show symfony/* before upgrading; older Laravel applications may still be locked to Symfony 5.4 or early 6.x components.
  • Symfony 8 support does not mean every app should resolve Symfony 8. Confirm the PHP version required by Symfony 8 and by the rest of the dependency graph before forcing the highest set.
  • Use composer update --with-all-dependencies rather than editing only the package constraint. Major Symfony changes often require coordinated updates of related components.
  • After upgrading, clear cached config, routes, and compiled views in local and CI environments. Stale config cache is a common source of “works in one environment only” failures.
  • If the package exposes drivers, macros, or custom adapters, confirm those extension points still exist in 2.0. Major refactors to PHP 8.1 can change method signatures, return types, and constructor arguments.
  • Debug integration issues with composer show vendor/package, php artisan about, Telescope logs, and a minimal reproduction test. Avoid debugging through the full application when a single service-level test can isolate the package.
  • Commit composer.lock for applications and test both --prefer-lowest and --prefer-stable in CI. This catches constraint mistakes introduced by the new Symfony support range.
  • Read the upgrade guide before changing code. In a 2.0 release, assume public API, config keys, and supported framework versions may have changed even when the release notes are short.
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.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource