2013-03-15 43 views
5

Tôi đang sử dụng IntelliJ IDEA 12 để phát triển một ứng dụng web PHP bằng cách sử dụng khuôn khổ CodeIgniter. Do cách CI instantiates đối tượng và phương pháp, IDEA nghĩ họ không tồn tại khi chúng được gọi là:IntelliJ IDEA 12 không tìm thấy lớp CodeIgniter, ném lỗi

enter image description here

Như bạn thấy, tôi nhận được những squigglies cam gây phiền nhiễu dưới mỗi lớp CodeIgniter/phương pháp duy nhất Tôi cố gắng sử dụng.

Dưới đây là đoạn code cho lớp CI_Controller, đưa ra một số cái nhìn sâu sắc vào cách họ đang tạo ra các đối tượng:

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; 
    } 
} 

Có cách nào tôi có thể nhận IntelliJ IDEA hoặc là bỏ qua các lỗi (nhưng lỗi không khác), hoặc làm cho nó để tìm các đối tượng trên của riêng mình?

Lưu ý: Tôi đã từng sử dụng PHPStorm, một IDE PHP xây dựng trên nền tảng IntelliJ IDEA, và nó đã làm điều tương tự khi nó đến với CodeIgniter.

+0

sử dụng 'Aptana'. Hoàn hảo cho 'Codeigniter'. –

+1

@YogeshSuthar Tôi sẽ xem xét nó, nhưng tôi muốn một giải pháp để làm cho CI làm việc với IntelliJ IDEA. –

+0

Tìm kiếm trên google cho thấy bạn không phải là người duy nhất gặp sự cố. Tôi sử dụng Sublime Text và nó hoàn hảo cho CI - thậm chí còn có một vài plugin hoàn thành mã được tạo bởi các bên thứ ba. –

Trả lời

8

Tôi đã giải quyết vấn đề này bằng cách theo dõi this guide. Nó có nghĩa là cho PHPStorm nhưng cũng làm việc cho IntelliJ IDEA (có lẽ cả WebStorm nữa!). Nó thực sự rất đơn giản. Bản tóm tắt cơ bản:

  1. Đã lưu mã PHP sau vào gốc dự án của tôi. Đó là về cơ bản chỉ là một bình luận 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. Tìm thấy /system/core/controller.php/system/core/model.php bên trong IntelliJ IDEA và clicked- đúng> Mark as Plain Text.

3. Xong! Nó hoạt động tuyệt vời, không có lỗi sai và hoàn thành mã!

enter image description here

+0

Có lẽ nên thực hiện một số tìm kiếm tốt hơn. Đăng này như là một câu trả lời để hy vọng giúp đỡ bất cứ ai khác có vấn đề này (tìm kiếm nó cho thấy rất nhiều câu hỏi và không có câu trả lời). –

+0

nó không làm việc cho tôi tôi nhận được lỗi như chức năng undefined form_open() vv –

0

Đây là giải pháp mà làm việc cho tôi: https://github.com/Stunt/Codeigniter-autocomplete/

Tôi đang sử dụng phpStorm nhưng tôi tưởng tượng nó sẽ làm việc với IDEA.

Không cần đánh dấu tệp là văn bản thuần túy. Chỉ cần thả tập tin autocomplete.php vào thư mục application/config và nó hoạt động. Tôi nghi ngờ các liên kết tại github sẽ đi xấu nhưng chỉ trong trường hợp đây là nội dung của tập tin.

<?php 
// help IDE(s) support Codeigniter 2.0 
/** 
* @property CI_DB_active_record $db 
* @property CI_DB_forge $dbforge 
* @property CI_Benchmark $benchmark 
* @property CI_Calendar $calendar 
* @property CI_Cart $cart 
* @property CI_Config $config 
* @property CI_Controller $controller 
* @property CI_Email $email 
* @property CI_Encrypt $encrypt 
* @property CI_Exceptions $exceptions 
* @property CI_Form_validation $form_validation 
* @property CI_Ftp $ftp 
* @property CI_Hooks $hooks 
* @property CI_Image_lib $image_lib 
* @property CI_Input $input 
* @property CI_Language $language 
* @property CI_Loader $load 
* @property CI_Log $log 
* @property CI_Model $model 
* @property CI_Output $output 
* @property CI_Pagination $pagination 
* @property CI_Parser $parser 
* @property CI_Profiler $profiler 
* @property CI_Router $router 
* @property CI_Session $session 
* @property CI_Sha1 $sha1 
* @property CI_Table $table 
* @property CI_Trackback $trackback 
* @property CI_Typography $typography 
* @property CI_Unit_test $unit_test 
* @property CI_Upload $upload 
* @property CI_URI $uri 
* @property CI_User_agent $user_agent 
* @property CI_Validation $validation 
* @property CI_Xmlrpc $xmlrpc 
* @property CI_Xmlrpcs $xmlrpcs 
* @property CI_Zip $zip 
* 
* 
* 
* These are samples entries to make my own functions work. 
* Remove these and add you custom ones. 
* @property Tank_auth $tank_auth 
* @property Users_model $users_model 
* @property Firms_model $firms_model 
* @property Firms_model_master $firms_model_master 
* 
* 
*/ 
class CI_Controller {}; 
class MY_Controller extends CI_Controller {}; 
/** 
* @property CI_DB_active_record $db 
* @property CI_DB_forge $dbforge 
* @property CI_Config $config 
* @property CI_Loader $load 
* @property CI_Session $session 
*/ 
class CI_Model {}; 
/* End of file autocomplete.php */ 
/* Location: ./application/config/autocomplete.php */ 
?> 

CẬP NHẬT cho CIv3: Nếu bạn đang sử dụng CodeIgniter V 3.x, hãy sử dụng thay thế này.

<?php 
/** 
* @property CI_DB_query_builder|CI_DB_postgre_driver $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.<br /> 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.<br />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,<br />replacing them with the data in the second param 
* @property CI_Profiler $profiler    This class enables you to display benchmark, query, and other data<br />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_Encryption $encryption   The Encryption Library provides two-way data encryption 
* @property CI_Table $table      HTML table generation<br />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_Form_validation $validation 
* @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... 
* @property Tank_auth $tank_auth 
* 
*/ 
class CI_Controller{} 
class MY_Controller extends CI_Controller {}; 
/** 
* @property CI_DB_query_builder|CI_DB_postgre_driver $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.<br /> 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.<br />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,<br />replacing them with the data in the second param 
* @property CI_Profiler $profiler    This class enables you to display benchmark, query, and other data<br />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_Encryption $encryption   The Encryption Library provides two-way data encryption 
* @property CI_Table $table      HTML table generation<br />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_Form_validation $validation 
* @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... 
* @property Tank_auth $tank_auth 
*/ 
class CI_Model {}; 

Tôi không thể nhận tín dụng cho tất cả điều này. Tôi tìm thấy rất nhiều trong số này nhưng không nhớ ở đâu. Tôi đã cần phải thêm một số để làm cho nó hoàn thành mặc dù.

+0

nó không làm việc kẻ thù tôi tôi đang sử dụng CI-3 bất kỳ đề nghị hoặc giúp đỡ ... –

+0

tôi nhận được lỗi như undefined function form_open() vv ... –

+0

Tính năng này có hoạt động đối với các chức năng CI được xây dựng không? Nếu vậy, nó hoạt động chính xác. Để làm cho nó hoạt động với các chức năng tùy chỉnh của bạn, hãy sửa đổi các mục bên dưới: * Đây là các mục mẫu để làm cho các chức năng của riêng tôi hoạt động. * Xóa các mục này và thêm bạn tùy chỉnh. –

Các vấn đề liên quan