Sorry for bad English.
I have 1 model file from the composer, previously I used CI version 3.0.x with the following configuration it's working.
config.php
PHP Code:
$config['composer_autoload'] = FCPATH . 'vendor/autoload.php';
autoload.php
PHP Code:
$autoload['model'] = array('Crud');
My Model location in `ROOTPROJECT/vendor/package/my-package/models/Crud.php'
PHP Code:
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Crud extends CI_Model {
public function __construct() { parent::__construct(); }
public function createData($table, $data) {
$this->db->insert($table, $data);
return $this->db->error();
}
}
From the composer side has also been made autoload Crud.php
Code:
{
"autoload": { "classmap": ["models/Crud.php"] }
}
When I update the CI system to version 3.1.6 by following all previous changes, it is not working.
Code:
An uncaught Exception was encountered
Type: RuntimeException
Message: Unable to locate the model you have specified: Crud
Filename: /media/LocalDiskD/DorkSQLi/htdocs/CodeIgniter/system/core/Loader.php
Line Number: 344
I am trying to change the file
system / core / Loader.php line 324, the result
nothing error.
PHP Code:
if ( ! class_exists($model, FALSE)) { ... }
↓
if ( ! class_exists($model, TRUE)) { ... }
CodeIgniter 3.1.6 system/core/Loader.php line 323-350
PHP Code:
$model = ucfirst($model);
if ( ! class_exists($model, FALSE))
{
foreach ($this->_ci_model_paths as $mod_path)
{
if ( ! file_exists($mod_path.'models/'.$path.$model.'.php'))
{
continue;
}
require_once($mod_path.'models/'.$path.$model.'.php');
if ( ! class_exists($model, FALSE))
{
throw new RuntimeException($mod_path."models/".$path.$model.".php exists, but doesn't declare class ".$model);
}
break;
}
if ( ! class_exists($model, FALSE))
{
throw new RuntimeException('Unable to locate the model you have specified: '.$model);
}
}
elseif ( ! is_subclass_of($model, 'CI_Model'))
{
throw new RuntimeException("Class ".$model." already exists and doesn't extend CI_Model");
}
CodeIgniter 3.0.1 system/core/Loader.php line 293-320
PHP Code:
$model = ucfirst(strtolower($model));
if ( ! class_exists($model))
{
foreach ($this->_ci_model_paths as $mod_path)
{
if ( ! file_exists($mod_path.'models/'.$path.$model.'.php'))
{
continue;
}
require_once($mod_path.'models/'.$path.$model.'.php');
if ( ! class_exists($model, FALSE))
{
throw new RuntimeException($mod_path."models/".$path.$model.".php exists, but doesn't declare class ".$model);
}
break;
}
if ( ! class_exists($model, FALSE))
{
throw new RuntimeException('Unable to locate the model you have specified: '.$model);
}
}
elseif ( ! is_subclass_of($model, 'CI_Model'))
{
throw new RuntimeException("Class ".$model." already exists and doesn't extend CI_Model");
}
how to avoid the error without having to change the file system CodeIgniter?