DbFace allows you creating your own API by PHP for public access. DbFace use CodeIgniter Framework to provide a flexible PHP development environment.
Create or edit Cloud code
- Sign in DbFace with Administrator or Developer account
- Tap “Settings” -> “Cloud Code”
You will see all available cloud code you already created in the selected database connection.
Tap the “Create API Code” button to create a new API code.
- API Name: this will be the Public URL for accessing the cloud
- Disabled: if you want disable the public URL temporarily, you can check the “Disable” checkbox
- Open: open the cloud code in debug mode
- Save Changes: after editing the cloud code, do not forget click “Save Changes” button to save the cloud code
Access Cloud Code
You will find the cloud code public URL in the list page.
Cloud Code Alerts
Cloud Code Alerts can be configured to run either on an interval or at a scheduled time.
To run a Cloud Code Alert on an interval, select the interval option and choose from every 10 minutes, 30 minutes, 1 hours, 4 hours, 12 hours, or 24 hours.
By selecting the ‘Schedule’ option, cloud code alerts can be set to run at a specific time in specific timezone.
You can change the timezone at config/config.inc.php file
$config['crontab_schedule_timezone'] = date_default_timezone_get();
You can find all the available timezone here.
Enable Cloud Code Alerts
You need to enable crontab to enable Cloud Code Alerts feature.
php index.php crontab crontab_key
The crontab_key can be found in config/config.inc.php
$config['crontab_execution_key'] = '6193rW3iTjXo7N3S27t2I2GA6OJjo03S';
Please modify the default crontab_execution_key, or other people can invoke the crontab if they know your dbface installation URL.
We recommend you run the cron application every 10 minutes.
sudo crontab -e
add
*/10 * * * * php /var/www/dbface/index.php cron 6193rW3iTjXo7N3S27t2I2GA6OJjo03S
Disabling Cloud Code Alerts
Cloud Code Alerts can be disabled by turning off the “Enable Alerts” switch under the Cloud Code footer.
!!! tip “Please Notice” Cloud Code only be available on On-premises installation or Enterprise plan.
Templates
You can also create your own Smarty templates that can be used in Cloud Code or PHP Report.
!!! tip “Please Notice” Use {$ and } in templates. We already put predefined variables, parameters and other global variables into the smarty instance.
Use templates in Cloud Codes
We already create $smarty variable and put all available variables into the smarty instance. You can also use $db variable that point to your current database connection.
$smarty->display('my-template.tpl');
Use templates in PHP reports
$smarty->display('my-template.tpl');
Scheduled Jobs
As default, All scheduled jobs are executed by 10 minutes. You can drag the “Drag” icon to order the scheduled jobs.
Triggers
User Login
/**
* Trigger function when user sign in DbFace successfully.
*
* @param $params
*
* @return bool
*/
function _trigger_login($params) {
return TRUE;
}
Pre Application
/**
* trigger function before user execute an application
*
* @param $params: appid, creatorid, userid
*/
function _trigger_pre_application($params) {
return TRUE;
}
Post Application
/**
* trigger function after user execute an application
*
* @param $params: appid, creatorid, userid
*/
function _trigger_post_application($params) {
return FALSE;
}
Custom Menu for Viewers
You can define custom menu for viewers in DbFace by an editable YAML file.
DbFace Modules
DbFace modules are pure php applications that be able to installed in DbFace. You can install DbFace modules as DbFace menu items. So we can access these php applications in DbFace navigation system.