CodeIgniter Forums
CI3 Code Completion for IntelliJ PHPStorm/IDEA - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: External Resources (https://forum.codeigniter.com/forumdisplay.php?fid=7)
+--- Forum: Addins (https://forum.codeigniter.com/forumdisplay.php?fid=13)
+--- Thread: CI3 Code Completion for IntelliJ PHPStorm/IDEA (/showthread.php?tid=63641)



CI3 Code Completion for IntelliJ PHPStorm/IDEA - _this - 11-22-2015

Hello CI's community !

I needed a code completion plugin for my IDE but couldn't find one that fitted my needs (CI2 only compatible, reserved to another IDE, etc...). So I decided to rewrite the CI's part of phpStorm-CC-Helpers made by topdown in order to make it CI3's friendly Smile

So after a hard work of about 20 minutes, I had a PHPStorm CC "plugin" for CI3 !

You can find it on my github Big Grin

Please report any "bug", add comments, stars, etc...


RE: CI3 Code Completion for IntelliJ PHPStorm/IDEA - cartalot - 11-22-2015

hey i'm very appreciative of this because i'm slowly using phpstorm and i think it could be very helpful for codeigniter developers. another approach is to use an autocomplete file in application/config/autocomplete.php

it seems like it might be simpler because you don't have to do anything special -- no include path or project root required -- it will load automatically. also you can put your model names in it so you don't need a separate file for models. finally with this approach you do not need to mark any system core files as plain text.

what i have not figured out is an elegant solution for getting the database result methods to autocomplete.
UPDATE -- its 2016 and the database methods now autocomplete with versions of PHPStorm 10 from early 2016.

anyway here is autocomplete file i'm using -- this is rough but i know it works on phpstorm 9 and beta 10 with CI 3
UPDATE -- works much better with PHPStorm 10 so if you are using 9 - upgrade.

PHP Code:
<?php defined('BASEPATH') OR exit('No direct script access allowed');


 
   /*
     *
     *   _________ Codeigniter 3 Autocomplete for PHPStorm ____________
     *
      1) Controllers
      2) Models
      3) Create named properties for your application Models,
      can then access the model methods from the controller.

      WORK IN PROGRESS, this is still rough but does work for CI 3

    */

 
   /**
     *
     *                         * ************** for Controllers *****************
     *============ Codeigniter Core System ================
     * @property CI_Benchmark $benchmark              Benchmarks
     * @property CI_Config $config                    This class contains functions that enable config files 
     * @property CI_Controller $controller            This class object is the super class that every library in.
     * @property CI_Exceptions $exceptions            Exceptions Class
     * @property CI_Hooks $hooks                      Provides a mechanism to extend the base system 
     * @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_Output $output                    Responsible for sending final output to browser
     * @property CI_Profiler $profiler                Display benchmark results, queries you have run, etc
     * @property CI_Router $router                    Parses URIs and determines routing
     * @property CI_URI $uri                          Retrieve information from URI strings
     * @property CI_Utf8 $utf8                        Provides support for UTF-8 environments
     *
     *
     * @property CI_Model $model                      Codeigniter Model Class
     *
     * @property CI_Driver $driver                    Codeigniter Drivers
     *
     *
     *============ Codeigniter Libraries ================
     *
     * @property CI_Cache $cache                      Caching
     * @property CI_Calendar $calendar                This class enables the creation of calendars
     * @property CI_Email $email                      Permits email to be sent using Mail, Sendmail, or SMTP.
     * @property CI_Encryption $encryption            The Encryption Library provides two-way data encryption.
     * @property CI_Upload $upload                    File Uploading class
     * @property CI_Form_validation $form_validation  Form Validation class
     * @property CI_Ftp $ftp                          FTP Class
     * @property CI_Image_lib $image_lib              Image Manipulation class
     * @property CI_Migration $migration              Tracks & saves updates to database structure
     * @property CI_Pagination $pagination            Pagination Class
     * @property CI_Parser $parser                    Template parser
     * @property CI_Security $security                Processing input data for security.
     * @property CI_Session $session                  Session Class
     * @property CI_Table $table                      HTML table generation
     * @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_User_agent $user_agent            Identifies the platform, browser, robot, or mobile
     * @property CI_Xmlrpc $xmlrpc                    XML-RPC request handler class
     * @property CI_Xmlrpcs $xmlrpcs                  XML-RPC server class
     * @property CI_Zip $zip                          Zip Compression Class
     *
     *
     *                          *============ Database Libraries ================
     *
     *
     * @property CI_DB_query_builder $db   Database
     * @property CI_DB_forge $dbforge     Database
     * @property CI_DB_result $result                 Database
     *
     *
     *
     *
     *                            *============ Codeigniter Depracated  Libraries ================
     *
     * @property CI_Javascript $javascript            Javascript (not supported
     * @property CI_Jquery $jquery                    Jquery (not supported)
     * @property CI_Encrypt $encrypt                  Its included but move over to new Encryption Library
     *
     *
     *                            *============ Codeigniter Project Models ================
     *  Models that are in your project. if the model is in a folder, still just use the model name.
     *
     *  load the model with Capital letter $this->load->model('People') ;
     *  $this->People-> will show all the methods in the People model
     *
     * @property People $People
     *
     * @property Products $Products
     *
     */
 
   class CI_Controller
    
{
 
   }

 
   ;

 
   /**
     *
     * ************** For Models  *****************
     *
     *
     *============ Codeigniter Core System ================
     * @property CI_Benchmark $benchmark              Benchmarks
     * @property CI_Config $config                    This class contains functions that enable config files 
     * @property CI_Controller $controller            This class object is the super class that every library in.
     * @property CI_Exceptions $exceptions            Exceptions Class
     * @property CI_Hooks $hooks                      Provides a mechanism to extend the base system 
     * @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_Output $output                    Responsible for sending final output to browser
     * @property CI_Profiler $profiler                Display benchmark results, queries you have run, etc
     * @property CI_Router $router                    Parses URIs and determines routing
     * @property CI_URI $uri                          Retrieve information from URI strings
     * @property CI_Utf8 $utf8                        Provides support for UTF-8 environments
     *
     *
     * @property CI_Model $model                      Codeigniter Model Class
     *
     * @property CI_Driver $driver                    Codeigniter Drivers
     *
     *
     *============ Codeigniter Libraries ================
     *
     * @property CI_Cache $cache                      Caching
     * @property CI_Calendar $calendar                This class enables the creation of calendars
     * @property CI_Email $email                      Permits email to be sent using Mail, Sendmail, or SMTP.
     * @property CI_Encryption $encryption            The Encryption Library provides two-way data encryption.
     * @property CI_Upload $upload                    File Uploading class
     * @property CI_Form_validation $form_validation  Form Validation class
     * @property CI_Ftp $ftp                          FTP Class
     * @property CI_Image_lib $image_lib              Image Manipulation class
     * @property CI_Migration $migration              Tracks & saves updates to database structure
     * @property CI_Pagination $pagination            Pagination Class
     * @property CI_Parser $parser                    Template parser
     * @property CI_Security $security                Processing input data for security.
     * @property CI_Session $session                  Session Class
     * @property CI_Table $table                      HTML table generation
     * @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_User_agent $user_agent            Identifies the platform, browser, robot, or mobile
     * @property CI_Xmlrpc $xmlrpc                    XML-RPC request handler class
     * @property CI_Xmlrpcs $xmlrpcs                  XML-RPC server class
     * @property CI_Zip $zip                          Zip Compression Class
     *
     *
     *                          *============ Database Libraries ================
     *
     *
     * @property CI_DB_query_builder $db   Database
     * @property CI_DB_forge $dbforge     Database
     * @property CI_DB_result $result                 Database
     *
     *
     *
     *                            *============ Codeigniter Depracated  Libraries ================
     *
     * @property CI_Javascript $javascript            Javascript (not supported
     * @property CI_Jquery $jquery                    Jquery (not supported)
     * @property CI_Encrypt $encrypt                  Its included but move over to new Encryption Library
     *
     *
     *                            *============ Codeigniter Project Models ================
     *  Models that are in your project. if the model is in a folder, still just use the model name.
     *
     *  load the model with Capital letter $this->load->model('People') ;
     *  $this->People-> will show all the methods in the People model
     *
     * @property People $People
     *
     * @property Products $Products
     *
     */
 
   class CI_Model
    
{
 
   }

 
   ;


 
   /* End of file autocomplete.php */
 
   /* Location: ./application/config/autocomplete.php */ 



RE: CI3 Code Completion for IntelliJ PHPStorm/IDEA - _this - 11-23-2015

Hey,

Thanks for the feedback, I'll have a look at your method tonight, it seems really interesting as you said it has several benefits so I might include it as well in the github project.

Seeya!


RE: CI3 Code Completion for IntelliJ PHPStorm/IDEA - cartalot - 11-23-2015

yes - i hasten to add its not my method -- it was what i picked up from stack etc, so please feel free to use it however you want.

also check out the phpstorm 10 beta -- have they silently added more support for codeigniter? or maybe its overall improvement? but now with a similar autocomplete file it works for Codeigniter 2 !! (it did not work before for CI 2 without doing those other modifications like marking core files as plain text)


RE: CI3 Code Completion for IntelliJ PHPStorm/IDEA - _this - 11-23-2015

Ok, fine, I'll take a look tonight at your code gathering and if I include it (I might), will credit you and SO's community Smile

I use PHPStorm 10.0.2 (or maybe 10.2, can't remember) at work but I use IDEA 14.1.4 at home.

I just added CI-CC today at work and I observed a few changes yes ! It's more efficient in auto-completes and doc popup and coloured syntax is far way better... e.g. $this->vendor->get(): vendor is syntax-coloured differently from $this and the method next to it === much more clear !

UPDATE: GitHub updated including your method, tested and approved !

I also updated the include path methods to be only one file Smile

Added custom libraries support !


RE: CI3 Code Completion for IntelliJ PHPStorm/IDEA - mnat - 12-15-2015

Sorry for my English...

Eeverything is ok when not using extends for CI_Controller. 
When I use MY_Controller, autocomplete doesn't work.

PHP Code:
class TestA extends CI_Controller {
 
   public function good  
        
//autocomplete works fine
 
   }
}

class 
MY_Controller extends CI_Controller /*...*/ }
class 
TestB extends MY_Controller {
 
   public function bad  
        
//autocomplete doesn't work
 
   }




RE: CI3 Code Completion for IntelliJ PHPStorm/IDEA - cartalot - 12-22-2015

Quote:When I use MY_Controller, autocomplete doesn't work.

have not tried this myself but did you try putting MY_Controller in the autocomplete file?
(similar to how controller and model are called)


RE: CI3 Code Completion for IntelliJ PHPStorm/IDEA - cartalot - 04-10-2016

update - am using phpstorm 10.0.3
have not tried autocomplete in a while with codeigniter 3, but i am today and can confirm has gotten easier
in the autocomplete sample above - for your application models - i wrote that you had write out the model name property in upper case first
and then call it from controller upper case first

but it looks like this little hack is not necessary anymore!
you can now do it all with lower case

another big improvement - ci db query methods are showing automatically in the method!!!
for things like: $query->num_rows()
(that was not working at all before)


RE: CI3 Code Completion for IntelliJ PHPStorm/IDEA - _this - 04-11-2016

Hi Cartalot,

Thanks for the feedback Smile
Does the repository need a fix? If so, can you make a PR? I can't look at it right now, so it would really help me a lot!

Have a good day Wink


RE: CI3 Code Completion for IntelliJ PHPStorm/IDEA - cartalot - 04-25-2016

i don't know if it needs a fix just reporting this for people considering using phpstorm. otherwise - i kind of still prefer my method - just call the file autocomplete.php and drop it in application/config folder. works instantly, no other configuration necessary, and no setting of files to plain text. which is cool - however this is only going to be super cool when we have a way to automatically include our models.