I am trying to integrate the Ruler library available on the link below into my codeigniter project.
https://github.com/bobthecow/Ruler
I installed and configured it using the steps given in these links. But still not able to use the methods from the library. I tried the example code from the library but its not working. Looks like the Ruler library is not getting with my project and so the methods are not resolved. Looking for help to get this working.
The Steps I followed are
- Run composer require ruler/ruler to install the library
- a new folder named vendor is created and it contains the ruler library code
- I move it to application folder in my project
- Edit the
application/config/config.php
, find the setting$config['composer_autoload']
and Set it to TRUE - load the library using this code to use in controller
$this->load->library('ruler)
https://forum.codeigniter.com/thread-61112-post-315197.html#pid315197
How to use composer packages in codeigniter?
https://arjunphp.com/how-to-use-composer-with-codeigniter/
Integrate phpgrid with codeigniter
How to adapt a PHP library to Codeigniter?
To test if its working, I added this function in my controller and on executing it, i do not see any echo
I executed the steps given in the links in my question. To check if everything is working, i created a new function in my controller like this public
function testing() { $rb = new RuleBuilder; $rule = $rb->create( $rb->logicalAnd( $rb['minNumPeople']->lessThanOrEqualTo($rb['actualNumPeople']), $rb['maxNumPeople']->greaterThanOrEqualTo($rb['actualNumPeople']) ), function() { echo 'YAY!'; } ); $context = new Context(array( 'minNumPeople' => 5, 'maxNumPeople' => 25, 'actualNumPeople' => function() { return 6; }, )); $rule->execute($context); // "Yay!"