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
Object Enumerator

Object Enumerator Laravel Package

sebastian/object-enumerator

Traverses arrays and object graphs to enumerate every referenced object, including nested structures and circular references. A small utility from Sebastian Bergmann's PHP testing stack, commonly pulled in by PHPUnit to walk object graphs safely.

View on GitHub
Deep Wiki
Context7

sebastian/object-enumerator is a small, dependency-free PHP library that walks array structures and object graphs to enumerate every object referenced—directly or indirectly—from a given value. It inspects object properties and nested arrays, making it easy to process a full object tree without writing recursive traversal code yourself.

It is part of the PHPUnit ecosystem and works well for testing utilities, serializers, and analysis tools.

  • Enumerates all objects reachable from arrays or objects
  • Traverses nested and deeply structured object graphs
  • Minimal, single-method API with no configuration
  • Composer-installable as a runtime or dev dependency
Frequently asked questions about Object Enumerator
What is sebastian/object-enumerator used for?
It provides a single Enumerator::enumerate() method that walks arrays and object graphs and returns every referenced object, including nested ones. It is a single-purpose utility from the PHPUnit toolchain and is useful for programmatic deep inspection, graph-shape assertions, leak checks, serialization analysis, or internal inspector commands. It is not intended for readable debugging output.
How do I install sebastian/object-enumerator in a Laravel project?
Use composer require --dev sebastian/object-enumerator only when you have a direct call site. In many Laravel projects it is already present transitively through sebastian/comparator and phpunit/phpunit. Installing it explicitly converts an implicit dependency into a declared dev dependency; it adds no service provider or configuration.
Is sebastian/object-enumerator Laravel-specific or framework-agnostic?
It is framework-agnostic and has no service provider, configuration, or Laravel coupling. That makes it trivially compatible with Laravel 10, 11, and 12, but also irrelevant to MVC, domain, or service-layer code. Treat it as test and tooling infrastructure rather than application architecture.
Do I need to require sebastian/object-enumerator if I already use PHPUnit or Pest?
Usually no: PHPUnit and Pest pull it in through sebastian/comparator, so it is likely already in vendor/. Check composer show sebastian/object-enumerator and composer.lock before adding it. Promote it to an explicit require-dev entry only if your code directly calls Enumerator::enumerate().
Which Laravel versions support sebastian/object-enumerator?
There is no Laravel version constraint because the package has no Laravel coupling. Compatibility depends on the PHP version supported by the installed object-enumerator release and on your PHPUnit or Pest version. Laravel 10, 11, and 12 do not introduce any package-specific integration requirements.
Does sebastian/object-enumerator support PHP 8.2 and PHP 8.3?
The release notes for 7.0.0 and 8.0.0 contain wording about PHP 8.2 and PHP 8.3 that must be checked against the installed composer.json require constraint. Across sebastian packages this phrasing often indicates a minimum PHP version floor, but do not assume it. Verify the constraint for each CI matrix PHP version before planning an upgrade.
Can I use sebastian/object-enumerator in production Laravel code?
It should be dev-only with zero production call sites. Use require-dev and call it from test helpers or CI-only artisan commands, not from controllers, jobs, or domain services. For human debugging, dump() and VarDumper are better; this package is for programmatic enumeration.
How does sebastian/object-enumerator handle cycles in object graphs?
The enumerator is described as cycle-safe and returns each referenced object without looping forever on circular references. It performs depth-first traversal with no depth cap, predicate, or result limit. Large hydrated Eloquent graphs or container dumps can therefore be slow and memory-hungry, so scope inputs carefully.
What are alternatives to sebastian/object-enumerator for inspecting objects in Laravel?
Use VarDumper or dump() for readable debugging, json_encode for simple serializable data, Arr:: helpers for array-only work, and spl_object_id when you only need identity tracking. Choose object-enumerator when you need identity-level, cycle-safe traversal of nested object graphs. It is not a replacement for a full profiler or memory analyzer.
How should I test or maintain a Laravel wrapper around sebastian/object-enumerator?
If you add a wrapper, keep it in tests/ or a CI-only command and cover it with a small fixture containing nested arrays and circular object references. Declare sebastian/object-enumerator as require-dev and let PHPUnit or Pest drive its version rather than pinning it independently. Avoid a production wrapper, document the named caller, and re-check the PHP constraint on each PHP or PHPUnit major upgrade.
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.
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
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels