kphoen/rulerz-bundle
Symfony bundle that integrates the RulerZ rule engine, providing configuration and services for defining, compiling, and applying business rules to objects and collections. It simplifies dependency injection and rule management in Symfony applications.
Architecture fit. RulerZ is a rule-engine/specification library: business rules are expressed once (as a string DSL or a Specification object) and then either evaluated in-memory against PHP objects/arrays or compiled to a target query language (Doctrine DQL, Elasticsearch DSL, SQL). kphoen/rulerz-bundle is not the engine — it is a thin Symfony integration layer that registers the rulerz service, wires per-target compilers, exposes the spec parser, and adds a Twig extension (rulerz_can, rulerz_can_see). The architectural value is real: it moves authorization/eligibility/filtering logic out of controllers and Eloquent/Doctrine chains into a testable, declarative layer.
Integration feasibility — the headline risk. This package cannot be dropped into a Laravel application. It is a Symfony Bundle: it depends on symfony/framework-bundle (^2.8|^3.x), registers through Kernel::registerBundles(), and ships a DependencyInjection\Extension. Laravel has no bundle registry, no compiler passes, no Bundle class. Adoption therefore has two distinct paths:
kphoen/rulerz library and write a ~100–200 line RulerzServiceProvider plus a Blade directive to replace the Twig extension. This is the only credible route, and it means the package under review contributes essentially nothing but reference configuration.Technical risk. High. Last release 2016-06-11 — roughly nine years stale — with 37 stars and zero dependents. That combination is the signature of an abandoned integration shim. Expect: PHP 8 incompatibilities (old reflection usage, deprecated dynamic properties, each()-era idioms), Symfony 4+ DI incompatibilities (setSynthetic, private-service semantics, removed bundle inheritance), and unconstrained transitive pins that will fight a modern composer.lock. The underlying kphoen/rulerz core is itself dormant. MIT license removes legal friction but not maintenance burden.
Key questions.
symfony/expression-language (actively maintained, works fine in Laravel) is a direct substitute.Stack fit. Assume Laravel 10/11 on PHP 8.2/8.3. The bundle's constraints (php >=5.6, symfony/framework-bundle ^2.8|^3.0) hard-conflict; composer require kphoen/rulerz-bundle will fail resolution immediately. Do not spend time trying to force it with --ignore-platform-reqs — you would install a Symfony kernel into a Laravel app for no benefit.
Recommended migration path.
kphoen/rulerz core only, if the spike justifies it at all.App\Providers\RulerzServiceProvider: bind RulerZ\RulerZ as a singleton, instantiate the compiler(s) you need (DoctrineCompiler only if you actually use Doctrine; otherwise array/NativeCompiler), and register a RuleFactory/spec parser.@rulerzCan(...)) or, better, a Gate-adjacent helper so authorization stays in one place.RulerZ\Spec\Specification rather than raw DSL strings in config — this keeps rules unit-testable and IDE-navigable.Resources/config/*.yml as documentation for which services to bind; do not install the YAML.Compatibility. Treat the core library as legacy: pin it exactly, run the full test suite on every PHP minor upgrade, and isolate all RulerZ\* imports behind your own RuleEngine interface so a future swap to symfony/expression-language or a hand-rolled evaluator is a one-file change.
Sequencing. (a) Two-day spike proving one real rule end-to-end against a representative model; (b) go/no-go against the ExpressionLanguage alternative; (c) if go, wrap behind an interface and ship with contract tests; (d) only then migrate existing ad-hoc rule logic. Never sequence this ahead of a feature that needs it.
Maintenance. You are adopting a fork on day one. Budget 1–2 engineer-days per PHP minor release for compatibility patching, plus an unbounded tail for security issues in the DSL parser. Upstream will not help; there is no maintainer to file against.
Support. Community-only, and effectively no community: 37 stars and 0 dependents means no Stack Overflow corpus, no third-party blog coverage, and thin official docs. Internal documentation and a runbook for "rule fails to parse in production" are mandatory, not optional.
Scaling. In-memory evaluation is O(rules × rows) in PHP — fine for hundreds of entities, not for report generation over thousands. Compiled DQL/SQL pushdown scales well but couples you to a specific query builder and makes the compiled output hard to review. The failure pattern to watch in Laravel specifically is per-model evaluation inside a loop: foreach ($users as $u) { $rulerz->satisfies($u, $rule); } over 10k rows is an N+1-shaped performance cliff, and lazy-loading relations referenced in a rule turns it into a query storm.
Failure modes.
composer outdated gate and a calendar reminder for the fork.Ramp-up. The DSL has non-obvious syntax (notably #-prefixed parameter binding and target-specific operator availability). Expect 1–2 days for a mid-level engineer to be productive, plus ongoing friction for anyone who has not internalized which operators compile to which backend.
TPM recommendation. Do not adopt kphoen/rulerz-bundle. It is a Symfony-only shim with a nine-year-old last release and zero dependents, and it cannot be installed into a Laravel application. If a declarative rule layer is genuinely required, prototype symfony/expression-language first — same product outcome, actively maintained, framework-agnostic — and only fall back to forking kphoen/rulerz core if compiled query pushdown proves to be a hard requirement.
How can I help you explore Laravel packages today?