A PHP implementation of the Specification pattern for writing business rules and filtering multiple data sources.
RulerZ is a PHP library that implements the Specification pattern, providing a unified way to define business rules using a simple, SQL-like domain-specific language (DSL). It enables developers to apply these rules across various data sources—such as arrays, objects, and database queries—without fetching unnecessary data, thereby separating business logic from data access.
PHP developers working on applications that require consistent business rule enforcement across multiple data layers, such as those using Doctrine ORM/DBAL, Laravel Eloquent, Elasticsearch, or other supported backends.
Developers choose RulerZ for its data-agnostic DSL that allows writing rules once and applying them to any supported datasource, along with its ability to optimize queries by converting rules directly into database queries for supported backends, avoiding performance overhead from pre-fetching data.
Powerful implementation of the Specification pattern in PHP
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Provides a simple, SQL-like DSL that allows writing business rules once and applying them consistently across arrays, objects, and databases, as shown in the quick usage examples.
Supports diverse data sources like Doctrine, Elasticsearch, and Laravel Eloquent via additional libraries, enabling seamless rule application without code duplication.
Converts rules directly into database queries for backends like Doctrine, avoiding pre-fetching data and improving performance, highlighted as a 'killer feature' in the README.
Encapsulates rules in reusable, testable specification classes, promoting better code organization and maintainability, as emphasized in the philosophy section.
The project is explicitly marked as no longer maintained in the README, posing risks for security updates, bug fixes, and compatibility with newer PHP versions or frameworks.
Requires separate composer packages for each backend (e.g., Doctrine, Elasticsearch), increasing setup complexity and potential dependency conflicts.
The SQL-like DSL may not support advanced business logic or custom functions without extending the library, which can be cumbersome for complex scenarios.
Teams must learn a new DSL and integrate it with existing data access layers, which can slow initial development compared to using native ORM tools.