IntelliJ IDEA 12找不到CodeIgniter类,抛出错误 [英] IntelliJ IDEA 12 not finding CodeIgniter classes, throwing errors

查看:791
本文介绍了IntelliJ IDEA 12找不到CodeIgniter类,抛出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用IntelliJ IDEA 12来开发使用CodeIgniter框架的PHP Web应用程序。由于CI实例化对象和方法,IDEA认为它们在调用时不存在:

I'm using IntelliJ IDEA 12 to develop a PHP web application using the CodeIgniter framework. Due to the way CI instantiates objects and methods, IDEA thinks they don't exist when they're called:

正如你所看到的,我在每个单独的CodeIgniter类下得到那些烦人的橙色squigglies方法我尝试使用。

As you can see, I get those annoying orange squigglies under every single CodeIgniter class/method I try to use.

以下是 CI_Controller 类的代码,创建对象:

Here's the code for the CI_Controller class, giving some insight into how they're creating the objects:

class CI_Controller {

    private static $instance;

    /**
     * Constructor
     */
    public function __construct()
    {
        self::$instance =& $this;

        // Assign all the class objects that were instantiated by the
        // bootstrap file (CodeIgniter.php) to local class variables
        // so that CI can run as one big super object.
        foreach (is_loaded() as $var => $class)
        {
            $this->$var =& load_class($class);
        }

        $this->load =& load_class('Loader', 'core');

        $this->load->initialize();

        log_message('debug', "Controller Class Initialized");
    }

    public static function &get_instance()
    {
        return self::$instance;
    }
}

有任何方法我可以获得IntelliJ IDEA忽略这些错误(但不是其他错误),或者让它自己找到对象?

Is there any way I can get IntelliJ IDEA to either ignore these errors (but not other errors), or get it to find the objects on its own?

注意:我曾经使用PHPStorm, IntelliJ IDEA平台,它做了同样的事情,当它来到CodeIgniter。

Note: I used to use PHPStorm, a PHP IDE build on the IntelliJ IDEA platform, and it did the same thing when it came to CodeIgniter.

推荐答案

我通过以下本指南。它是为PHPStorm,但也适用于IntelliJ IDEA(也许是WebStorm太!)。这很简单,实际上。基本概述:

I solved this by following this guide. It was meant for PHPStorm but works for IntelliJ IDEA as well (probably WebStorm too!). It was very simple, actually. A basic recap:


  1. 在我的项目根目录中保存了以下PHP代码。它基本上只是一个PHPDoc注释:




    <?php  die('This file is not really here!');

    /**
     * ------------- DO NOT UPLOAD THIS FILE TO LIVE SERVER ---------------------
     *
     * Implements code completion for CodeIgniter in phpStorm
     * phpStorm indexes all class constructs, so if this file is in the project it will be loaded.
     * -------------------------------------------------------------------
     * Drop the following file into a CI project in phpStorm
     * You can put it in the project root and phpStorm will load it.
     * (If phpStorm doesn't load it, try closing the project and re-opening it)
     * 
     * Under system/core/
     * Right click on Controller.php and set Mark as Plain Text
     * Do the same for Model.php
     * -------------------------------------------------------------------
     * This way there is no editing of CI core files for this simple layer of code completion.
     *
     * PHP version 5
     *
     * LICENSE: GPL http://www.gnu.org/copyleft/gpl.html
     *
     * Created 1/28/12, 11:06 PM
     *
     * @category
     * @package    CodeIgniter CI_phpStorm.php
     * @author     Jeff Behnke
     * @copyright  2009-11 Valid-Webs.com
     * @license    GPL http://www.gnu.org/copyleft/gpl.html
     * @version    2012.01.28
     */

    /**
     * @property CI_DB_active_record $db              This is the platform-independent base Active Record implementation class.
     * @property CI_DB_forge $dbforge                 Database Utility Class
     * @property CI_Benchmark $benchmark              This class enables you to mark points and calculate the time difference between them.
Memory consumption can also be displayed. * @property CI_Calendar $calendar This class enables the creation of calendars * @property CI_Cart $cart Shopping Cart Class * @property CI_Config $config This class contains functions that enable config files to be managed * @property CI_Controller $controller This class object is the super class that every library in.
CodeIgniter will be assigned to. * @property CI_Email $email Permits email to be sent using Mail, Sendmail, or SMTP. * @property CI_Encrypt $encrypt Provides two-way keyed encoding using XOR Hashing and Mcrypt * @property CI_Exceptions $exceptions Exceptions Class * @property CI_Form_validation $form_validation Form Validation Class * @property CI_Ftp $ftp FTP Class * @property CI_Hooks $hooks Provides a mechanism to extend the base system without hacking. * @property CI_Image_lib $image_lib Image Manipulation class * @property CI_Input $input Pre-processes global input data for security * @property CI_Lang $lang Language Class * @property CI_Loader $load Loads views and files * @property CI_Log $log Logging Class * @property CI_Model $model CodeIgniter Model Class * @property CI_Output $output Responsible for sending final output to browser * @property CI_Pagination $pagination Pagination Class * @property CI_Parser $parser Parses pseudo-variables contained in the specified template view,
replacing them with the data in the second param * @property CI_Profiler $profiler This class enables you to display benchmark, query, and other data
in order to help with debugging and optimization. * @property CI_Router $router Parses URIs and determines routing * @property CI_Session $session Session Class * @property CI_Sha1 $sha1 Provides 160 bit hashing using The Secure Hash Algorithm * @property CI_Table $table HTML table generation
Lets you create tables manually or from database result objects, or arrays. * @property CI_Trackback $trackback Trackback Sending/Receiving Class * @property CI_Typography $typography Typography Class * @property CI_Unit_test $unit_test Simple testing class * @property CI_Upload $upload File Uploading Class * @property CI_URI $uri Parses URIs and determines routing * @property CI_User_agent $user_agent Identifies the platform, browser, robot, or mobile devise of the browsing agent * @property CI_Validation $validation //dead * @property CI_Xmlrpc $xmlrpc XML-RPC request handler class * @property CI_Xmlrpcs $xmlrpcs XML-RPC server class * @property CI_Zip $zip Zip Compression Class * @property CI_Javascript $javascript Javascript Class * @property CI_Jquery $jquery Jquery Class * @property CI_Utf8 $utf8 Provides support for UTF-8 environments * @property CI_Security $security Security Class, xss, csrf, etc... */ class CI_Controller{} /** * @property CI_DB_active_record $db This is the platform-independent base Active Record implementation class. * @property CI_DB_forge $dbforge Database Utility Class * @property CI_Benchmark $benchmark This class enables you to mark points and calculate the time difference between them.
Memory consumption can also be displayed. * @property CI_Calendar $calendar This class enables the creation of calendars * @property CI_Cart $cart Shopping Cart Class * @property CI_Config $config This class contains functions that enable config files to be managed * @property CI_Controller $controller This class object is the super class that every library in.
CodeIgniter will be assigned to. * @property CI_Email $email Permits email to be sent using Mail, Sendmail, or SMTP. * @property CI_Encrypt $encrypt Provides two-way keyed encoding using XOR Hashing and Mcrypt * @property CI_Exceptions $exceptions Exceptions Class * @property CI_Form_validation $form_validation Form Validation Class * @property CI_Ftp $ftp FTP Class * @property CI_Hooks $hooks Provides a mechanism to extend the base system without hacking. * @property CI_Image_lib $image_lib Image Manipulation class * @property CI_Input $input Pre-processes global input data for security * @property CI_Lang $lang Language Class * @property CI_Loader $load Loads views and files * @property CI_Log $log Logging Class * @property CI_Model $model CodeIgniter Model Class * @property CI_Output $output Responsible for sending final output to browser * @property CI_Pagination $pagination Pagination Class * @property CI_Parser $parser Parses pseudo-variables contained in the specified template view,
replacing them with the data in the second param * @property CI_Profiler $profiler This class enables you to display benchmark, query, and other data
in order to help with debugging and optimization. * @property CI_Router $router Parses URIs and determines routing * @property CI_Session $session Session Class * @property CI_Sha1 $sha1 Provides 160 bit hashing using The Secure Hash Algorithm * @property CI_Table $table HTML table generation
Lets you create tables manually or from database result objects, or arrays. * @property CI_Trackback $trackback Trackback Sending/Receiving Class * @property CI_Typography $typography Typography Class * @property CI_Unit_test $unit_test Simple testing class * @property CI_Upload $upload File Uploading Class * @property CI_URI $uri Parses URIs and determines routing * @property CI_User_agent $user_agent Identifies the platform, browser, robot, or mobile devise of the browsing agent * @property CI_Validation $validation //dead * @property CI_Xmlrpc $xmlrpc XML-RPC request handler class * @property CI_Xmlrpcs $xmlrpcs XML-RPC server class * @property CI_Zip $zip Zip Compression Class * @property CI_Javascript $javascript Javascript Class * @property CI_Jquery $jquery Jquery Class * @property CI_Utf8 $utf8 Provides support for UTF-8 environments * @property CI_Security $security Security Class, xss, csrf, etc... */ class CI_Model{}

2。在IntelliJ IDEA中找到 /system/core/controller.php /system/core/model.php clicked->标记为纯文本。

2. Found /system/core/controller.php and /system/core/model.php inside of IntelliJ IDEA and right clicked->Mark as Plain Text.

3。完成!它工作伟大,没有更多的错误,和代码完成!

3. Done! It works great, no more false errors, and code completion!

>

这篇关于IntelliJ IDEA 12找不到CodeIgniter类,抛出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆