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

Psl Laravel Package

azjezz/psl

PSL is a PHP standard library inspired by hhvm/hsl, offering consistent, well-typed, async-ready APIs for collections, networking, I/O, cryptography, terminal UI, and type-safe validation—replacing fragile PHP primitives with predictable alternatives. Requires PHP 8.4+.

View on GitHub
Deep Wiki
Context7

PHP Standard Library

Frequently asked questions about Psl
What is PSL (php-standard-library) and how does it fit into a Laravel application?
PSL is a PHP standard library inspired by hhvm/hsl that provides consistent, well-typed APIs for collections, networking, I/O, cryptography, terminal UI, async, and type-safe validation. In a Laravel app it works as a stricter alternative to raw arrays, str_ helper functions, and callback-based async rather than a framework replacement. Most teams adopt it selectively, using PSL for DTOs and validation while Eloquent and the service container keep handling persistence and wiring.
How do I install PSL in a Laravel project with Composer?
Run composer require azjezz/psl, which is the package name for this repository, and confirm your runtime satisfies PHP 8.4 or newer. PSL is a plain library and not a Laravel package, so there is no service provider registration or config publishing step. Commit your composer.lock so CI and production resolve the same version.
Does PSL require PHP 8.4, and which Laravel versions can use it?
Yes, PSL requires PHP 8.4 or higher, so it fits naturally with Laravel 11 and later projects already running on PHP 8.4. Older Laravel apps on PHP 8.1 to 8.3 cannot install it without upgrading the runtime first. Check your deployment images and CI matrix before adding the dependency.
Should I replace Laravel Collections with PSL Vec, Dict, and Set?
Not wholesale. PSL collections are immutable and strictly typed, which is excellent for DTOs and domain logic, while Illuminate\Support\Collection is mutable, macro-friendly, and tightly coupled to Eloquent results. A common pattern is PSL collections inside domain services and Laravel Collections at the HTTP and persistence boundaries, converting at the edges.
How does PSL Async with fibers compare to Laravel queues and Horizon?
PSL Async is built on PHP fibers and offers structured concurrency for lightweight in-process work, whereas Laravel queues and Horizon are durable, process-separated job systems with retries and monitoring. PSL does not replace them; it can complement batch processing or real-time API paths where you want fibers without a queue hop. Bridging PSL fibers with Laravel's promise and callback based job flow needs careful sequencing, so isolate it to specific services such as workers.
Can PSL Type numeric() help with Laravel request validation?
Yes. Type numeric() keeps numeric strings from query parameters, form posts, and CSV imports in their original form instead of silently casting them, and it coerces Stringable values such as Laravel's Stringable, backed enums, and money or quantity value objects cleanly. That makes it useful for validating and normalizing untrusted input before it reaches your models or Eloquent. It is the most Laravel-relevant addition in PSL 6.3.0.
What are the risks of upgrading PSL from 6.2.1 to 6.3.0 in production?
There are no declared breaking changes, and the Composer constraint bump from ^6.2 to ^6.3 is low effort. The main behavioral change is that PSL's HTTP client now raises a ProtocolException on invalid or unsupported Transfer-Encoding headers instead of falling back to Content-Length. Audit any PSL-based egress before bumping, add ProtocolException handling, and expect a small burst of new static-analysis findings if you use Dict diff().
How does the PSL HTTP client ProtocolException change affect my Laravel egress?
PSL's HTTP client now throws ProtocolException when it encounters invalid or unsupported Transfer-Encoding, including repeated fields, and it rejects conflicting Content-Length values in HTTP/1.1 and H2 while still accepting identical duplicates. If your Laravel app reaches third-party APIs or internal proxies through PSL, wrap those calls and handle the new exception path. If you rely on Guzzle or Symfony HttpClient instead, this change does not apply to your egress.
Can I adopt PSL gradually in an existing Laravel codebase?
Yes, PSL is modular, so you can start with a single component such as Type validation or Vec for DTOs without touching the rest of the application. Be aware of the stateful versus immutable mismatch: Eloquent, sessions, and caching assume mutable state, so keep PSL at the boundaries and in pure domain code. Hybrid patterns such as PSL for DTOs and Laravel for persistence work well and keep upgrade cost low.
Does PSL support PHPStan and Psalm in Laravel projects?
PSL ships Psalm and PHPStan plugins that surface type errors early, which makes gradual adoption in a Laravel codebase much safer. They help catch mismatches between PSL's strict types and Laravel's dynamically typed helpers before runtime. Expect to tune your static analysis baseline on the first run, particularly around Eloquent's dynamic properties and relationships.
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.
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log