illuminate/conditionable
Illuminate/Conditionable provides the Conditionable trait, adding when() and unless() methods to Laravel classes. Run callbacks conditionally without verbose if statements, keeping fluent method chains clean and readable. Lightweight and dependency-free, it ships as part of the Laravel framework.
What this package actually is. illuminate/conditionable is not a third-party utility — it is the read-only, subtree-split distribution of the Conditionable trait from laravel/framework, published by the Laravel team under MIT. It ships one trait (Illuminate\Support\Conditionable) exposing when() and unless() on any class that uses it. Registry signals in the brief — 0 dependents, stars attributed to the parent repo — are artifacts of monorepo splitting and understate adoption badly: this code is installed in effectively every Laravel application via illuminate/support, illuminate/collections, and illuminate/database. Any assessment that reads it as an "unofficial reimplementation" is measuring the wrong artifact, and that misframing should be corrected before it drives a decision.
Architecture fit: high, but usually invisible. For a Laravel application the trait is already present transitively; adding a direct requirement changes nothing functionally. The genuine architectural fit is narrower and sharper: (a) framework-agnostic PHP libraries that want fluent conditionals without dragging in all of illuminate/support; (b) shared internal packages (DTOs, builders, service objects) that must not assume a full Laravel runtime. In a full Laravel app the correct posture is "present, not declared."
Integration feasibility: trivial. Zero configuration, zero dependencies, zero bootstrapping. The one detail worth flagging to engineers is that the package name and the namespaced class diverge (illuminate/conditionable → Illuminate\Support\Conditionable), which trips up dependency audits and import greps.
Technical risk: low, and almost entirely version-graph risk rather than code risk. The trait is ~60 lines of pure PHP with no I/O, no parsing, no network surface. Real risks:
illuminate/* set, not a loud error.$default argument on when(); code written against 12.x and resolved to an older major will fail at runtime, not at install time.when() silently wins over the trait — no fatal, but divergent semantics.Key questions for the team:
Illuminate\Support\Conditionable directly, or is the trait only inherited through framework base classes?laravel/framework in lockstep, and who enforces it?$default argument or unless() semantics that are major-gated?Stack fit. Laravel 10/11/12: already installed, no action required — treat as part of the platform, not the dependency inventory. Non-Laravel PHP 8.x services and internal Composer libraries: genuinely useful, and the only context where a direct requirement is justified. Symfony or other-framework codebases: not applicable.
Migration path. There is no runtime migration — the trait is API-identical whether reached via the split package or via illuminate/support, so any code using it continues to work unchanged if the dependency posture shifts. The only "migration" is administrative: correcting the dependency declaration so it reflects reality.
Compatibility and sequencing.
composer why illuminate/conditionable and composer show illuminate/conditionable to confirm it is transitive and identify which major is resolved. Do this before any change; it is the whole audit.illuminate/conditionable to require with a constraint matching the lowest framework major you support; if the trait appears only in test doubles, put it in require-dev instead.when()/unless(), rename or wrap rather than relying on trait precedence.Guardrail to communicate. Do not let engineers add illuminate/conditionable to a Laravel application's composer.json as a "safety" measure. It is a no-op that creates a version constraint someone will later have to reconcile during a framework upgrade.
Maintenance: effectively nil. Upstream is maintained by the Laravel team with the framework's release cadence and MIT licensing; there is no separate roadmap, no deprecation stream, and no configuration to age. Budget zero engineering hours. The only recurring cost is the CI guardrail that keeps any direct constraint aligned with the framework major.
Support. Documentation lives in the Laravel docs (collections/conditionals), not in the package — engineers searching the package name for guidance will find little, which is a discoverability wrinkle, not a support gap. Security advisories arrive through the framework's advisory channel rather than a package-specific feed; if the org tracks per-package CVE feeds, this package will look permanently stale and should be excluded from that alerting to avoid noise.
Scaling. Irrelevant at any realistic volume — one conditional branch and a closure invocation per call. The only measurable cost is closure allocation in extremely tight loops (large collection pipelines over hundreds of thousands of items); the fix is a plain if in that hot path, not a change in dependency.
Failure modes to plan for:
illuminate/* set. Symptom: missing methods, puzzling runtime errors after an unrelated composer update. Detection: assert the resolved framework major in CI.when()'s third argument. Code assumes $default support that the resolved major does not provide.when() shadows the trait and behaves differently from every other when() in the codebase.laravel/framework.Ramp-up: under 15 minutes. Engineers already use when() on Collections and Eloquent builders, so the concept is pre-loaded. The only teachable gap is split-package literacy — understanding that illuminate/* packages are framework components, that their versions move with the framework, and that a direct requirement is a package-authoring tool, not an application-installation step. Put that in one paragraph of the platform onboarding doc and it is settled.
Bottom line for the roadmap. This is not a build/buy decision and should not consume a decision slot. Adopt it implicitly as a platform component in applications; adopt it explicitly only where a reusable library needs fluent conditionals without Laravel's full support layer. The measurable lever is dependency hygiene — keeping declared constraints honest and aligned — not capability, cost, or risk reduction.
How can I help you explore Laravel packages today?