laminas/laminas-stdlib
Utility components for PHP from the Laminas project: data structures, array and string helpers, hydrators, validators, option objects, and more. A shared toolbox used across Laminas and usable standalone in any PHP application.
Start by installing the package via Composer: composer require laminas/laminas-stdlib. It’s intentionally lightweight and dependency-light—ideal for use in standalone scripts, custom frameworks, or alongside Laravel. Your first use case will likely be hydrating objects from request data. For example, use Hydrator\ClassMethodsHydrator to convert a request payload (e.g., from an API controller) into a domain object:
use Laminas\Hydrator\ClassMethodsHydrator;
$hydrator = new ClassMethodsHydrator();
$user = $hydrator->hydrate($requestPayload, new User());
Check the official docs for quick reference; the library is well-documented with clear, minimal examples for each component.
GetSetStrategy, StrategyInterface) for nested objects or enum handling.$_GET/$_POST access with Filter\InputFilter or Request\Parameters to validate and cast inputs—especially useful in CLI tools or micro-frameworks.ArrayObject subclasses (e.g., GenericArrayObject) for type-safe collections in domain models—no need to reinvent “has this key?” or “pluck all values” logic.Message + Result classes to build structured, serializable event payloads (e.g., for event-sourcing or audit trails).Utils\ArrayUtilities::dot() for flattening nested arrays (e.g., for config merging or Laravel’s cache tagging), or Utils\StringUtilities::isJson() in middleware for content-type decisions.ClassMethodsHydrator uses method names (getFoo() ↔ foo), not property names—ensure your DTOs follow PSR-1 conventions or extend ArraySerializable.StrategyInterface if you need to preserve null vs. omit keys.Hydrator\Strategy\EnumStrategy (if available in your version) to hydrate backed enums cleanly—otherwise, write a custom strategy.ArraySerializable trait’s toArray() often trips developers when hydrating from DB arrays—use ClassMethodsHydrator with exposeMethods(false) to hydrate only via __set() or properties.laminas/laminas-stdlib in command handlers or jobs where Laminas’ InputFilter or hydration patterns improve data integrity over raw validated() arrays.How can I help you explore Laravel packages today?