This lib method only affected for single file class library.
For using 3rd party library like from composer
you can read it from 3rd library section.
Lib method from class SENE_Controller is for loading a library class into controller.
The library will be instantiate as part of properties on SENE_Controller.
Without an alias, the instantiate library object will be same as filename without extension php.
Load method has 3 parameter, there is the library filename
, library alias
and embeeding type
.
$this->lib(string $filename_location[, string $alias[, string $embeeding_type="lib"]])
The method lib location always relatives to kero/lib
directory.
So, if we have a library class under kero/lib/seme_email.php
We have to fill the first parameter with seme_email
without php extension.
Here is the example:
$this->load('seme_email');
With this example the seme_email library will be part of SENE_Controller class as seme_email
object
Here is the full example:
<?php class Blog extends SENE_Controller { public function __construct(){ parent::__construct(); $this->lib('seme_email'); } public function index(){ //executing the seme_email object $this->seme_email->from('daeng@example.com') .... } }
The alias purpose is for shorting the name of model that we create into SENE_Controller.
Alias can contain any alphanumeric and underscore.
Here is the example:
$this->lib('seme_email','eml');
With this example the seme_email will be part of SENE_Controller class as eml
object
Here is the full example:
<?php class Blog extends SENE_Controller { public function __construct(){ parent::__construct(); $this->lib('seme_email','eml'); } public function index(){ //executing the hello_model object $this->eml->from('daeng@example.com') .... } }
The embeeding_type purpose is for enable autoinstantiate object or not.
If value equal to lib
, the library will be instantiated with same name as library filename.
Otherwise, the library will be included only wihtout instantiated.
Here is the example:
$this->lib('seme_email','eml','inc');
With this example the seme_email will be part of SENE_Controller class as eml
object
Here is the full example:
<?php class Blog extends SENE_Controller { public function __construct(){ parent::__construct(); $this->lib('seme_email','eml','inc'); } public function index(){ //executing the hello_model object $eml = new Seme_Emal(); $eml->from('daeng@example.com'); .... } }