简体   繁体   中英

Unable to locate the specified class: Model.php codeigniter phpstorm

I am trying to add phpstorm autocomplete for codeigniter as seen in different quesiton.

The link provided: https://github.com/topdown/phpStorm-CC-Helpers

I commented out the specified files and added

* @property Test_model      $test_model

to my_models.php

When I try to load Test_model.php from my controller using:

$this->load->model('Test_model');

I get:

'Unable to locate the specified class: Model.php'

If I remove the load row and try:

$this->Test_model->insert_entry()

I get:

Message: Undefined property: Test::$Test_model

Test.php:

class Test extends CI_Controller {
  public function __construct(){
        parent::__construct();
  }
  public function modelTutorial(){
    $this->Test_model->insert_entry();
 }

Test_model.php

class Test_model extends CI_Model{

  public function __construct(){
      parent::__construct();
  }

  public function insert_entry(){
      die('asdasd');
  }
}

When creating models, you need to place the file in application/models/ and name the file in all lowercase - like yourfile_model.php

Change your file name from Test_model to test_model.php and call it on controller constructor

public function __construct(){
        parent::__construct();
        $this->load->model('test_model');
  }

Read manual Models

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM