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

Collection Laravel Package

php-standard-library/collection

Generic, object-oriented Vector, Map, and Set collections for PHP, available in both immutable and mutable variants. Part of the PHP Standard Library, offering a consistent, type-safe API for building and transforming collections.

View on GitHub
Deep Wiki
Context7

php-standard-library/collection provides generic, object-oriented Vector, Map, and Set collections for PHP, available in both immutable and mutable variants. Part of the PHP Standard Library, it offers predictable, type-safe data structures with a consistent API across collection types.

  • Immutable and mutable variants for safe or in-place operations
  • Generic Vector, Map, and Set implementations
  • Consistent, chainable object-oriented API
  • Predictable type safety for keys and values
  • Built as a standalone package for easy Composer integration
Frequently asked questions about Collection
What is php-standard-library/collection and what does it provide?
php-standard-library/collection is a generic, object-oriented collection package for PHP. It provides Vector, Map, and Set types in both immutable and mutable variants, with a consistent, type-safe API. In Laravel projects it can sit alongside native arrays and Laravel Collection for domain-layer data structures.
How do I install php-standard-library/collection in a Laravel app?
Install it with Composer using composer require php-standard-library/collection. The package is framework-agnostic, so no Laravel service provider or facade is required. After installation, import the specific Vector, Map, or Set classes you need and validate PHP version compatibility for your app.
Is php-standard-library/collection a replacement for Laravel Collection?
It is not a drop-in replacement for Laravel Collection and should not replace it globally. Laravel Collection is mutable, Eloquent-friendly, and integrated with framework APIs, while this package focuses on typed Vector, Map, and Set semantics with immutable and mutable variants. Use it behind an adapter in a bounded module and convert back to arrays or Laravel collections at application boundaries.
What is the difference between immutable and mutable collections in php-standard-library/collection?
Mutable variants allow in-place changes, while immutable variants return new collection instances when modified. Immutable collections are useful for domain snapshots, event-sourced state, and safe sharing across services, but they can add memory pressure in high-throughput paths. Mutable variants are better when a bounded operation needs lower overhead and controlled mutation.
Does php-standard-library/collection support generics and static analysis?
The package exposes generic types, but PHP generics are primarily enforced through docblocks and static analysis rather than runtime guarantees. Teams should rely on PHPStan or Psalm plus tests to validate type safety. Confirm the package's static-analysis story works with your existing baseline before adopting it widely.
Can I use php-standard-library/collection with Eloquent models and relationships?
It can accept Eloquent results at application boundaries, but it has no Eloquent relationship awareness, query-builder hooks, or model serialization conventions. A safe approach is to map query results into Vector, Map, or Set inside domain services and convert back before returning API resources or Eloquent relations. Handle models with relations and circular references carefully when serializing.
How should I serialize php-standard-library/collection objects for Laravel queues and cache?
Collections used in queue payloads, cache entries, events, or APIs must be serialized explicitly, typically by converting to arrays or a format your serializer supports. Validate serializer behavior for jobs and cache in your Laravel version, especially for immutable variants and nested objects. Do not assume Eloquent models with relations or circular references will serialize safely without tests.
Which Laravel and PHP versions are supported by php-standard-library/collection?
The package is framework-agnostic, so it can be used in Laravel apps, but exact PHP and Laravel version support should be verified against its Composer constraints and release metadata. The technical evaluation's best-fit context is a Laravel app on PHP 8.1+ with strict typing and static analysis. Validate compatibility with your project's PHP version, Laravel version, queue/cache serialization, and static-analysis setup before adoption.
Is php-standard-library/collection safe for production and well maintained?
Adoption signals are weak: the repository has about 1 star, 0 dependents, sparse maturity metadata, and release notes that defer to a separate monorepo. Treat it as a pilot-only tool for bounded use cases rather than a foundational dependency. Verify provenance, maintenance expectations, and rollback ownership before using it in production.
What are alternatives to php-standard-library/collection for typed collections in Laravel?
Credible alternatives include Laravel Collection, symfony/collection, ds, native arrays with typed wrappers, and custom domain-specific collection classes. Laravel Collection is the lowest-friction option for framework-integrated work, while typed wrappers can reduce dependency risk. Choose based on your need for immutable structures, set/map semantics, static analysis, and long-term support.
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.
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo
bernskioldmedia/laravel-harvest
bernskiold/laravel-data-scrubber
bernskiold/laravel-currency-converter
bernskiold/laravel-campaign-monitor
bernskioldmedia/laravel-autotranslate
siberfx/telegram-bot
roy-sandip/laravel-view-extended
gregsphotography/site-builder-core
roy-sandip/laravel-view
anodyne/blade-fluentui-icons
webx-ui/module-catalog-collections