- How do I install juststeveking/parameterbag in a Laravel application?
- Install it with Composer using composer require juststeveking/parameterbag:^2.0 on a PHP 8.0+ application. There is no service provider, config publishing, or migration step, so you can start using the class immediately. Before committing to a schedule, run composer update --dry-run against your actual Laravel version to confirm dependency resolution.
- Which PHP and Laravel versions does juststeveking/parameterbag support?
- Version 2.0 requires PHP 8.0 or newer and is blocked outright on PHP 7.4. The package has framework-agnostic code with Laravel support, but the last release was July 2021 and there is no public evidence of CI against PHP 8.3/8.4 or Laravel 11/12. Check the 2.0.0 require block for illuminate/* constraints and verify it resolves cleanly with your Laravel version today.
- Is parameterbag a replacement for Laravel Collection or Config Repository?
- No. It is a narrow value object that wraps an associative array with get, set, has, all, dot-notation access, defaults, ArrayAccess, and iteration. In Laravel it sits alongside Collection, Config Repository, and Symfony ParameterBag rather than replacing them. The important decision is which primitive your team is standardising on and why.
- How do I read nested values and provide defaults with ParameterBag?
- ParameterBag supports dot-notation nesting for reading values and defaults for missing keys, alongside get, set, has, and all. That lets you wrap related request parameters or payload data in a named object instead of threading fragile array keys through multiple layers. Check the package source or tests for the exact method names and default semantics before relying on them.
- Should I use a parameter bag or a DTO for request payloads?
- A parameter bag is untyped and flexible: string-keyed access returns mixed, so it relocates the what-is-in-this-array problem into a class but does not solve it. A DTO is the better fit when your real requirement is validated, typed structure. If you need validation or strong typing, choosing a bag is a common cause of failed adoption.
- Does juststeveking/parameterbag work outside Laravel?
- Yes. The package is framework-agnostic, dependency-free, and designed for any PHP 8.0+ application. Laravel support is first-class in the sense that it fits naturally in Laravel codebases, but there is no service provider contract or framework coupling to satisfy. You can use it in plain PHP, Symfony, or other frameworks.
- Is juststeveking/parameterbag maintained and safe for production?
- It has one maintainer, zero dependents, a last release in July 2021, and no published support or security policy. There is no evidence of CI against current PHP or Laravel versions, so treat it as unmaintained but stable rather than actively maintained. The very low exit cost is what makes the risk acceptable for many teams.
- Can I use ArrayAccess and iterate over a ParameterBag?
- Yes. The package provides ArrayAccess and iteration in addition to get, set, has, and all. That makes it convenient for code that expects array-like access while still giving you a named type. It does not add validation or strong typing, so keep that limitation in mind.
- What are the risks of mutating a ParameterBag passed between layers?
- A ParameterBag wraps an array inside an object, so instances passed between layers are shared references. Mutating a bag in one layer can silently change it in another, which is a design choice and a footgun. Name that risk explicitly, and clone or copy the bag when you need isolated changes.
- How hard is it to remove or replace parameterbag later?
- Exit cost is near zero: the class can be inlined or forked in under a day. That makes adoption a coding-standard decision with a small procurement step, not a platform commitment. Lead with that low exit cost when socialising the decision, and still review the 2.0.0 diff and dependency resolution first.