rulerz-php / pomm
Pomm compilation target for RulerZ
Requires
- php: >=7.1
- kphoen/rulerz: dev-master as 1.0.0
- pomm-project/cli: ^2.0
- pomm-project/foundation: ^2.0
- pomm-project/model-manager: ^2.0
Requires (Dev)
- behat/behat: ~3.0
- kphoen/rusty: dev-master
- liip/rmt: ^1.2
- phpunit/phpunit: ^7.1
- vlucas/phpdotenv: ~2.1
This package is auto-updated.
Last update: 2024-11-29 05:26:50 UTC
README
Pomm compilation target for RulerZ.
Usage
Pomm is one of the targets supported by RulerZ.
This cookbook will show you how to retrieve objects using Pomm and RulerZ.
Here is a summary of what you will have to do:
Configure Pomm
This subject won't be directly treated here. You can either follow the official documentation or use a bundle/module/whatever the framework you're using promotes.
Configure RulerZ
Once Pomm is installed and configured we can the RulerZ engine:
$rulerz = new RulerZ( $compiler, [ new \RulerZ\Pomm\Target\Pomm(), // this line is Pomm-specific // other compilation targets... ] );
The only Pomm-related configuration is the Pomm
target being added to the list
of the known compilation targets.
Filter your target
Now that both Pomm and RulerZ are ready, you can use them to retrieve data.
The Pomm
instance that we previously injected into the RulerZ engine
only knows how to use PommProject\ModelManager\Model\Model
so the first step
is to access the model to query:
$playerModel = $pomm['my_db']->getModel('\MyDb\PublicSchema\PlayerModel');
And as usual, we call RulerZ with our target (the Model
object) and our rule.
RulerZ will build the right executor for the given target and use it to filter
the data, or in our case to retrieve data from a database.
$rule = 'gender = :gender and points > :points'; $parameters = [ 'points' => 30, 'gender' => 'M', ]; var_dump( iterator_to_array($rulerz->filter($playerModel, $rule, $parameters)) );
That's it!
License
This library is under the MIT license.