Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter 3 HMVC has been broken

Using this HMVC plugin in Codeigniter. (https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/src/codeigniter-3.x/)

Running fine in another server, but in this server I am getting this error!

A PHP Error was encountered

Severity: 8192

Message: strpos(): Non-string needles will be interpreted as strings in the future. Use an explicit chr() call to preserve the current behavior

Filename: MX/Router.php

Line Number: 239

Backtrace:

File: /var/www/project.test/public/application/third_party/MX/Router.php
Line: 239
Function: strpos

File: /var/www/project.test/public/application/third_party/MX/Router.php
Line: 101
Function: _set_default_controller

File: /var/www/project.test/public/index.php
Line: 324
Function: require_once
like image 471
Amin Avatar asked Dec 01 '22 09:12

Amin


2 Answers

I change the line of codes on the function set_class like this:

    {
        //this is the original codes I commented
    /* $suffix = $this->config->item('controller_suffix');
        if (strpos($class, $suffix) === FALSE)
        {
            $class .= $suffix;
        }
        parent::set_class($class); 
    */

      //and change with this one
        $suffix = (string) $this->config->item('controller_suffix');
        if ($suffix && strpos($class, $suffix) === FALSE) {
            $class .= $suffix;
        }

        parent::set_class($class);
    }

Source: https://forum.codeigniter.com/thread-72393.html
like image 195
Arnes He Avatar answered Dec 04 '22 01:12

Arnes He


Just Update the function in Router.php File Path: application\third_party\MX\Router.php

public function set_class($class)
    {
    //  $suffix = $this->config->item('controller_suffix');
    //  if (strpos($class, $suffix) === FALSE)

    $suffix = (string) $this->config->item('controller_suffix');
    if ($suffix && strpos($class, $suffix) === FALSE)
    {
        $class .= $suffix;
    }
    parent::set_class($class);
}

After this it is working fine!

like image 35
Chandan Sharma Avatar answered Dec 03 '22 23:12

Chandan Sharma