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

Product Decisions This Supports

  • Build vs. Buy: Buy – PSL eliminates the need to reinvent core utilities (e.g., async, collections, networking, type validation) from scratch, accelerating development cycles for PHP-based systems. Ideal for teams prioritizing maintainability and type safety over custom implementations.
  • Roadmap Alignment:
    • Async-First Architecture: Enables structured concurrency (fibers) for high-performance APIs, microservices, or CLI tools (e.g., replacing ReactPHP/Amp with a more idiomatic PHP solution).
    • Type Safety: Reduces runtime errors in data pipelines (e.g., API validation, config parsing) by leveraging composable type systems (e.g., Type\shape() for DTOs). The new Type\numeric() validates integers, floats, and numeric strings while preserving the input type—useful when API contracts require "1.23" to remain a string.
    • Immutable Data Structures: Critical for state management in reactive UIs (e.g., Laravel Livewire, Inertia.js) or event-driven systems.
    • Protocol Hardening: Recent HTTP\Client fixes reject invalid Transfer-Encoding and conflicting Content-Length fields, reducing exposure to malformed or ambiguous HTTP responses in integrations and service-to-service calls.
  • Use Cases:
    • Backend Services: Replace ad-hoc array manipulations with functional collections (Vec, Dict) and async networking (TCP, HTTP).
    • CLI Tools: Build robust command-line apps with structured concurrency (e.g., parallel file processing, API polling).
    • Data Processing: Graph algorithms for dependency resolution (e.g., package managers, build systems) or hierarchical data (e.g., org charts, file trees).
    • Security: Cryptographic primitives (Hash, Random), type-safe input validation for APIs, and stricter HTTP response validation in the client.
    • Legacy Modernization: Gradually adopt PSL in Laravel/Lumen apps by wrapping native PHP functions (e.g., Vec\map() instead of array_map()).

When to Consider This Package

Adopt PSL if:

  • Your team uses PHP 8.4+ and prioritizes type safety, structured concurrency, or immutable data.
  • You’re building high-concurrency systems (e.g., real-time APIs, CLI tools) and want to avoid callback hell/promises.
  • You need composable validation (e.g., API request bodies, config files) with zero reflection overhead—including numeric fields that must preserve their original type.
  • Your project involves complex data relationships (graphs, trees) or functional programming patterns.
  • You’re migrating from ReactPHP/Amp or Symfony Components to a unified, async-first library.
  • You depend on HTTP client correctness and want stricter handling of malformed transfer encodings and content-length conflicts.

Look elsewhere if:

  • You’re constrained to PHP < 8.4 (PSL requires modern features like enums, attributes).
  • Your stack relies heavily on legacy PHP extensions (e.g., ext-curl for low-level HTTP) that PSL doesn’t wrap.
  • You prefer minimal dependencies—PSL is a large package (~50K LOC) with optional components.
  • Your use case is simple CRUD with no need for async/functional features (e.g., a basic WordPress plugin).
  • You’re already committed to ReactPHP or Amp for async and don’t want to rewrite existing code.

How to Pitch It (Stakeholders)

For Executives:

*"PSL is a game-changer for PHP’s scalability—it lets us build faster, safer, and more maintainable systems by replacing ad-hoc code with a batteries-included standard library. Think of it as PHP’s answer to Rust’s std or JavaScript’s util—but with structured concurrency (no more callback spaghetti), type-safe data handling (catching bugs at compile time), and a hardened HTTP client that rejects malformed protocol responses.

  • Reduces tech debt: Eliminates reinventing wheels for async I/O, collections, validation, or HTTP handling.
  • Future-proofs our stack: Aligns with PHP’s evolution (fibers, enums) and avoids vendor lock-in.
  • Attracts talent: Modern tooling like this is a huge differentiator for hiring engineers who want to work with cutting-edge PHP. Example: Our new real-time analytics pipeline could cut dev time by 40% using PSL’s Async and Graph components instead of stitching together ReactPHP + custom validation logic."*

For Engineering Teams:

*"PSL gives us superpowers for PHP development:

  • Async Made Easy: Write concurrent code with Async\main() and Async\concurrently()—no promises, no callbacks. Example: Spin up 100 TCP connections in one line.
  • Type Safety Without Overhead: Validate and coerce untrusted data (e.g., API inputs) with zero reflection using Type\shape(), plus Type\numeric() for numbers and numeric strings without losing the original type. No more runtime array_key_exists() hacks.
  • Immutable Data Structures: Vec, Dict, and Tree make state management predictable—critical for reactive apps or event sourcing.
  • Production-Ready Networking: Build TCP/TLS servers in 10 lines (no more stream_socket_server() boilerplate), and rely on stricter HTTP client validation for Transfer-Encoding and Content-Length.
  • Tooling Integration: Works seamlessly with Psalm, PHPStan, and Mago for static analysis. Trade-offs:
  • Learning curve: Functional programming patterns (e.g., map/filter on Vec) differ from imperative PHP.
  • Not a drop-in: Requires opting into PSL’s APIs (e.g., Vec\map() instead of array_map()). Recommendation: Start with one component (e.g., Type for validation or Async for a CLI tool) and expand as the team adopts it."*

Key Selling Points:

  • For PMs: Faster iteration, reduced risk of bugs in data pipelines and HTTP integrations.
  • For Devs: Modern tooling that feels like "PHP done right."
  • For Ops: More reliable async code with structured error handling and stricter protocol validation.
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.
roundly-consulting/kubernetes-api-for-laravel
roundly-consulting/plausible-for-laravel
gvp/gvp-laravel-template
metasyncsite/laravel-metasync-client
roundly-consulting/onboarding-for-laravel
andydefer/laravel-notification
adachsoft/cli-process-tester
jhaskell13/laraflow
sebastienheyd/boilerplate-media-manager
ccast/tagixo-primix
pretendtrue/laravel-builder
sawmainek/laravel-scout-tntsearch-driver
tomshaw/laravel-calendar-table
dibakar/laravel-ownership
steadrun/laravel-monitor
labyrinthe/connect-laravel
elmogy/layan
drewdan/sentinel-client
dskripchenko/laravel-llm
fatryst/nuonuo