Codeigniter 3 HMVC has been broken
Asked Answered
P

5

5

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
Pali answered 31/5, 2019 at 12:39 Comment(0)
A
3

This server is running PHP 7, please have a look at this pull request:

https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/pull-requests/39/php73-fix-for-error-message-strpos-non/diff

Adamsun answered 31/5, 2019 at 16:5 Comment(1)
this link is deadBonin
V
8

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
Veilleux answered 25/7, 2019 at 9:24 Comment(0)
H
8

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!

Hesychast answered 1/11, 2019 at 18:34 Comment(0)
A
3

This server is running PHP 7, please have a look at this pull request:

https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/pull-requests/39/php73-fix-for-error-message-strpos-non/diff

Adamsun answered 31/5, 2019 at 16:5 Comment(1)
this link is deadBonin
M
1

Change it to:

if (strpos($class, chr($suffix)) === FALSE)
Moralize answered 16/7, 2022 at 5:40 Comment(0)
M
0

This link is not working .It shows "Repository not found".

Milch answered 24/5, 2022 at 10:37 Comment(2)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Needful
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewBioclimatology

© 2022 - 2024 — McMap. All rights reserved.