2013-03-15 8 views
5

Ich verwende IntelliJ IDEA 12, um eine PHP-Webanwendung mit dem CodeIgniter-Framework zu entwickeln. Aufgrund der Art und Weise CI Objekte und Methoden instanziiert, denkt IDEA sie nicht existieren, wenn sie genannt werden:IntelliJ IDEA 12 keine CodeIgniter-Klassen finden, Fehler werfen

enter image description here

Wie Sie sehen können, habe ich die lästigen Orangen squigglies unter jedem einzelnen CodeIgniter Klasse/Methode erhalten Ich versuche zu benutzen.

Hier ist der Code für die CI_Controller Klasse, geben einen Einblick in, wie sie die Objekte erstellen möchten:

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

Gibt es eine Möglichkeit ich IntelliJ IDEA bekommen können diese Fehler (aber nicht andere Fehler entweder ignorieren) oder die Objekte selbst finden?

Hinweis: Ich habe früher PHPStorm verwendet, eine PHP-IDE, die auf der IntelliJ IDEA-Plattform aufbaut, und bei CodeIgniter hat es das Gleiche getan.

+0

Verwenden Sie 'Aptana'. Es ist perfekt für 'Codeigniter'. –

+1

@YogeshSuthar Ich werde mich darum kümmern, aber ich würde eine Lösung bevorzugen, um CI mit IntelliJ IDEA arbeiten zu lassen. –

+0

Eine Google-Suche zeigt, dass Sie nicht der einzige mit dem Problem sind. Ich benutze Sublime Text und es ist perfekt für CI - es gibt sogar ein paar Code Completion Plugins, die von Drittanbietern erstellt wurden. –

Antwort

8

Ich löste dies durch folgende this guide. Es war für PHPStorm gedacht, funktioniert aber auch für IntelliJ IDEA (wahrscheinlich auch WebStorm!). Es war wirklich sehr einfach. Eine grundlegende Zusammenfassung:

  1. Gespeichert den folgenden PHP-Code in meinem Projekt root. Es ist im Grunde nur ein PHPDoc Kommentar:
 
    <?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. /system/core/controller.php und /system/core/model.php Gefunden innerhalb von IntelliJ IDEA und rechts clicked-> Mark als Plain Text.

3. Fertig! Es funktioniert großartig, nicht mehr falsche Fehler und Code-Vervollständigung!

enter image description here

+0

Wahrscheinlich hätte man besser suchen müssen. Posted dies als eine Antwort auf hoffentlich helfen, jemand anderen mit diesem Problem (die Suche nach ihm zeigt eine Menge Fragen und keine Antworten). –

+0

es funktioniert nicht für mich Ich erhalte Fehler wie undefined Funktion form_open() etc. –

0

Dies ist die Lösung, die für mich gearbeitet: https://github.com/Stunt/Codeigniter-autocomplete/

ich PhpStorm bin mit aber ich glaube, es mit IDEA funktionieren würde.

Keine Notwendigkeit, Dateien als Nur-Text zu markieren. Legen Sie einfach die Datei autocomplete.php in den Ordner application/config und es funktioniert. Ich bezweifle, dass der Link bei Github schlecht wird, aber nur für den Fall hier ist der Inhalt der Datei.

<?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 */ 
?> 

UPDATE für CIV3: Wenn Sie CodeIgniter V 3.x verwenden, diese stattdessen verwenden.

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

Ich kann nicht für all dies Kredit nehmen. Ich habe viele davon gefunden, kann mich aber nicht erinnern, wo. Ich musste etwas hinzufügen, um es komplett zu machen.

+0

es funktioniert nicht foe mir ich benutze CI-3 keine weiteren Vorschläge oder Hilfe ... –

+0

ich bekomme Fehler wie undefinierte Funktion form_open() etc ... –

+0

Funktioniert es für integrierte CI-Funktionen? Wenn ja, funktioniert es richtig. Um es mit Ihren benutzerdefinierten Funktionen arbeiten zu lassen, ändern Sie die Einträge direkt darunter: * Dies sind Beispieleinträge, um meine eigenen Funktionen arbeiten zu lassen. * Entfernen Sie diese und fügen Sie benutzerdefinierte hinzu. –

Verwandte Themen