- Seme Framework
- version 4.0.3
- Requirements
- Download & Install
- Configuration
- Tutorials
- URI Routing
- Constants
- Global Variables
- Model
- View
- Controller
- cdn_url
- config
- constructor
- getAdditional
- getAdditionalBefore
- getAdditionalAfter
- getAuthor
- getCanonical
- getContentLanguage
- getDescription
- getIcon
- getJsContent
- getJsFooter
- getJsReady
- getKey
- getKeyword
- getLang
- getRobots
- getShortcutIcon
- getThemeElement
- getTitle
- input
- lib
- load
- loadCss
- loadLayout
- putThemeContent
- putJsContent
- putJsFooter
- putJsReady
- render
- resetThemeContent
- session
- setAuthor
- setCanonical
- setContentLanguage
- setDescription
- setIcon
- setKey
- setKeyword
- setLang
- setShortcutIcon
- setTheme
- setTitle
- Library
- CLI (command line interface)
- Core
- Issue
- Deployment
Lib method
The lib
method purpose is for loading a library class into a controller by generating (instantiating) a new property inside current controller class.
The new property name will be same as library filename without .php
extension in lowercase.
Basic Usage
Here is the basic usage for cdn_url
method from SENE_Controller
class.
$this->lib(string $lib_filename[, string $alias[, string $load_type="lib"]])
Parameters
This method has 1 required parameter and 2 optional parameter.
$lib_filename
The $lib_filename
value can be contain a string of library filename.
File location of library 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.
$alias
The $alias
value can be contain a string that override the name of property that instantiated by this method.
$load_type
The $load_type
determine load mechanism of this method.
Here is the list of compatible values:
- The
lib
value for loading the library and then automatically instantiate a property. - The
inc
value is for only load the library.
$load_type
value is not equal to lib
, the alias
parameter value will ignored.
Example
On this example, will show the implementation of lib
method without an alias.
<?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')
....
}
}
Using Alias
On this example will show the implementation of lib
method with an alias.
<?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')
....
}
}
Only Load
On this example will show the implementation of lib
method load only mode (inc
).
The library SEME_Email
have to instantiated manually.
<?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_Email();
$eml->from('daeng@example.com');
....
}
}