Welcome Guest, Not a member yet? Register   Sign In
Autocomplete
#1

Hi everyone,

I am new to this forum.

I am currently checking for myself what kind of FW I am going to use for my next project.
This far Ive been checking Zend 2, Cake 3, Laravel and some smaller FWs.

To my liking and previous experience with CI, CI3 is still damn easy to handle. Thats really nice, especially if you compare it to "younger upstarts" that tend to do a lot of "magic" behind the scenes with ORMs, getters, setters, huge config files and what not.

There is however one huge drawback. The way CI3 loads its components (lets say encryption for example) my IDE does not offer me autocompletion. This far Ive found some kind of hack for Netbeans and a small plugin, which sadly seems to be dropped from developement and seemingly was meant to build CRUD and MVC Skeletons.

It would be really great if autocompletion would not only work with core classes/objects, but with models as well. Currently I need to quickjump into the model and check the syntax of the method I want to use. That is a huge drag and might be a reason for not using CI3.

My search came up with the two solutions above, which arent really solutions. Am I missing some other way ?

My System:
MacOS 10.11
Netbeans 8.0.2


Best Regards,

Marlon.
Reply
#2

(This post was last modified: 10-19-2015, 11:06 AM by sv3tli0.)

I personally recommend PHPStorm (paid / has trial version).
There is helper https://github.com/topdown/phpStorm-CC-Helpers for CodeIgniter AutoLoad which you can add to have autocompleting..
Its a lot faster than NetBeans ..
(Mac OS + brew installed server Apache|Mysql|PHP)
Best VPS Hosting : Digital Ocean
Reply
#3

Thank you for your hint.

The plugin for PHPStorm does basically the same like the one for Netbeans. It helps the IDE indexing classes via a @property doc. This is helpful indeed, but needs a manual setup every time I create a new model. It might be possible to write a small command line script autofetching all models and adding them to the file. Ill try that tommorow. A cronjob should then do the trick.
Reply
#4

(This post was last modified: 10-19-2015, 01:51 PM by cartalot.)

hi -- just been learning phpstorm -- here is something that i'm still working through and is kind of crude but will autoload everything related to codeigniter in your controllers and models. This version is specifically for Codeigniter 3.

this will make available all codeigniter Libraries etc show up in code autocomplete when working in your controllers and models.
and Phpstorm will not show a warning error for those methods because it will recognize them.  

in the application/config directory
create a file called autocomplete.php
sample contents are below

to make your appliction model methods available, fill in the names of your models. 
there is People, Places, Things sample in there.

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 to be managed
 * @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 without hacking.
 * @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 Places $Places
 * @property Things $Things
 *
 */
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 to be managed
 * @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 without hacking.
 * @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 Places $Places
 * @property Things $Things
 *
 */
class CI_Model
{
}

;


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


 theres probably more for the database, and this breaks it out separately -- so everything for controller, and then everything for the model, which is crude. seeing my models come up in autocomplete -- and then my model methods, got me like  Big Grin 

you can get phpstorm 9 for 30 day free trial. AND they have an "early access" program thats free as well, and ongoing. 
https://confluence.jetbrains.com/display...ss+Program

i'm still just learning it, but wow - code clean up, refactoring tools, integrated ftp, create remote files on server, full git & version control, debugging, an HTTP client, database tool, easy integration with mamp, wamp, etc. and for an ide its pretty fast as well. 
Reply
#5

Yes models are a little bit shit as there is no real CI pluginfor PHP Storm.
How ever you are able to defina your models same wau as are defined the others libs..
Its some manual job but until there is a real plugin this is it.
Best VPS Hosting : Digital Ocean
Reply
#6

(10-19-2015, 11:08 PM)sv3tli0 Wrote: Yes models are a little bit shit as there is no real CI pluginfor PHP Storm.
How ever you are able to defina your models same wau as are defined the others libs..
Its some manual job but until there is a real plugin this is it.

Ive written a controller which can be used in CI3 to take care of that. Either start it from hand, or use a cronjob. It rewrites the file "my_models.php" provided in your github link. Should work in PHPStorm as well, it definitly is in Netbeans.

https://github.com/MarlonSchultz/CodeIgn...ete-Models

Its quick and dirty, but does the job. No error handling involved. I dont know if others might find this useful, but I guess so.
Reply
#7

Marlon this looks very cool will check it out. but please note that the Jeff Behnke version is for Codeigniter 2, not 3.
Reply
#8

Hello Cartalot,

you are right. Ill change the readme.
It should however work anyhow.
Do you have your files on Github ?
I could link you or fork your repo for further reference, or add your file above to my repo.
Which however did not work for my models in Netbeans. I am guessing this is a property inheritance thing.
I would need to check this.

Feel free to use my code as you wish.
Reply
#9

Come to think about it. My snippet could be easily changed to cover all the files in CI3. It just need to browse the files and then add them to a autocomplete file, like yours.
Reply
#10

hey please do what you will with the code i posted -- this was a very quick solution cobbled together from other solutions just to get me up and running for testing out phpstorm to make sure i could get it working.

HOWEVER i did label the libs as to which are deprecated in CI 3, which are core, which are for the database, etc.
so i think thats perhaps a good pattern because it gives everyone a quick overview of what to expect for the code complete,
and where to find the classes in the system files. also i think for the db in ci 3 it needs to be @property CI_DB_query_builder $db because its not called active record any longer. and there has to be some clever solution for accessing result methods from a query.

also i saw one recent solution on github where they did it as a helper, i didn't try it out but maybe there are advantages versus an autocomplete config file.
https://github.com/wenpeng/CodeIgniter-PhpStorm-Helper
Reply




Theme © iAndrew 2016 - Forum software by © MyBB