Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
start [2018/12/30 04:33]
francis94c
start [2019/03/01 22:19]
francis94c
Line 10: Line 10:
 Writing libraries for Splint also gives you the ability to write sub CodeIgniter applications that can be installed within a CodeIgniter application bundle. Writing libraries for Splint also gives you the ability to write sub CodeIgniter applications that can be installed within a CodeIgniter application bundle.
  
-To use Splint ​libraries, simply download and install the Splint client from [[https://​splint.cynobit.com/​downloads/​splint_setup.exe|here]] ​and run `splint install <​vendor\library_name>​at the root of your CodeIgniter project with a terminal.+To use Splint ​library, simply download and install the Splint client from [[https://​splint.cynobit.com/​downloads/​splint|here]], then run ''​splint install <​vendor\library_name>​'' ​at the root of your CodeIgniter project with a terminal.\\ 
 + 
 +You can then proceed to the library'​s page to view it's README on how to load it. You are most likely to load Splint libraries like this from within a controller.\\  
 +<code php> 
 +$this->​load->​splint("​vendor_name/​library_name",​ "​+LibraryClassName"​ , $params, "​alias"​);​ // Library loaded and initialized with $alias. 
 +$this->​alias->​someMethod();​ 
 +</​code>​ 
 + 
 +the ''​$this->​load->​splint();''​ method call is available when you patch your ''​Loader''​ class and fortunately,​ the Splint command line tool automatically does that for you the moment you install a library.  
 + 
 +Notice the ''​+''​ character before ''​LibraryClassName''​ in the above code. This tells splint to load a library from the specified package ''​vendor_name/​library_name''​ or rather search for a ''​php''​ file in with the name ''​LibraryClassName''​ from the libraries folder in the specified package and load it.\\  
 + 
 +You can also load ''​views'',​ ''​models'',​ ''​helpers''​ and ''​configs''​. All you need to do is use the required character as a prefix to the file name of the asset or php file you want to load from the package.\\  
 + 
 +== Auto-load Prefixes === 
 + 
 +The table below shows the characters and what they instruct the splint loader to load/search for. 
 + 
 +^ Character ^ To Load ^ 
 +| +         | Library |   
 +| *         | Model   | 
 +| -         | View    | 
 +| @         | Config ​ | 
 +| %         | Helpers | 
 + 
 +== Examples == 
 +For a library called ci-preference created by a vendor named francis94c, we can load a ''​Library'',​ ''​Model'',​ ''​View'',​ ''​Config'',​ or ''​Helper''​ in the manner shown below. 
 +<code php> 
 +// Library. 
 +$this->​load->​splint("​francis94c/​ci-preference",​ "​+CIPreferences",​ null, "​prefo"​);​ 
 +$this->​prefo->​get("​a_key",​ "​defaultVal"​);​ 
 +// Model. 
 +$this->​load->​splint("​francis94c/​ci-preference",​ "​*ModelClass",​ "​alias"​);​ 
 +$this->​alias->​someMethod();​ 
 +// View. 
 +$this->​load->​splint("​francis94c/​ci-preference",​ "​-view_header",​ array("​text"​ => "​Hello"​));​ 
 +// Config. 
 +$this->​load->​splint("​francis94c/​ci-preference",​ "​@config_file"​);​ 
 +// Helper. 
 +$this->​load->​splint("​francis94c/​ci-preference",​ "​%helper"​);​ 
 +</​code>​ 
 + 
 +== Load Multiple Libraries Or Resources == 
 + 
 +You can load libraries/​resources at the same time using an array of associative arrays of arrays as shown below. 
 + 
 +<code php> 
 +$autoload = array(); 
 +$autoload[] = array("​library"​ => array("​CIPreferences",​ null, "​alias"​));​ 
 +$autoload[] = array("​model" ​  => array("​CIPrefModel",​ "​alias"​)); ​        // Model with alias. 
 +$autoload[] = array("​model" ​  => "​CIPrefModel"​); ​                        // Model without alias. 
 +$autoload[] = array("​config" ​ => "​pref_config"​); ​                         
 +$autoload[] = array("​helper" ​ => "​pref_helper"​); ​                         
 +$autoload[] = array("​view" ​   => "​view_name"​); ​                           
 + 
 +$this->​load->​splint("​francis94c/​ci-preference",​ $autoload);​ 
 + 
 +// For loaded library. 
 +$this->​alias->​someMethod();​ 
 +</​code>​ 
 + 
 +== Topics == 
 + 
 +[[splint_loader|Load Splint Libraries]]\\  
 +[[developer:​create_project|Create a Splint Library]]\\