0

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

  1. Run composer require ruler/ruler to install the library
  2. a new folder named vendor is created and it contains the ruler library code
  3. I move it to application folder in my project
  4. Edit the application/config/config.php, find the setting $config['composer_autoload'] and Set it to TRUE
  5. 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!"

Manmohan
  • 720
  • 6
  • 18
Sid
  • 552
  • 6
  • 21
  • What exact steps did you execute? What exact error messages do you get? What is the output of `composer show`? – xabbuh Sep 11 '18 at 09:38
  • I followed the steps given in the various links in my question. I have updated the question with the function of my controller – Sid Sep 11 '18 at 09:50
  • Please write the steps in your question. If anyone in the future encounters the same problem and the links are dead by then, it will not be helpful. Also, people might not want to go through a lot of links to guess which part applies to you or not ;) – dbrumann Sep 11 '18 at 09:59
  • done, updated the question – Sid Sep 11 '18 at 10:12

0 Answers0