Documentation
Support
Cygnite has various global function uses internally in the framework itself. However you may use them for your application.
Displaying Formated Output
You may wish to view format output of array for debugging purpose, use show function. Simply pass first parameter as array to it.
$results = ['one', 'two'];
show($results);
Sometime you may wish to stop script execution after viewing the formatted output in the browser, simply pass true as second parameter.
show($results, true);
Getting Days Difference
$date = '2013-10-21 08:24:00';
echo days_diff($date);
By default the function will take current date and subtract the given date from it.
Splitting String Into Array
string_split("product-category", "-"); // By default it will split by dot(.)
Determine String Contains
string_has("product:value", ":"); // boolean
Application Instance
app();
Checking Is Console Application
Check if code is running via command line interface or web.
isCli();
Escaping HTML Entities
e($string);
Language Translation
trans('Hello, :user', array(':user' => $username), $locale = 'en-us');
Converting To Path
This function will replace dot or slash(/) to directory separator.
toPath('foo.bar'); // foo/bar
Getting CSRF Validator Instance
csrf(); // CSRF Validator instance
Getting CSRF Token
This function will return csrf token generated by CsrfValidator.
csrf_token();
Validating CSRF Token
validate_token($token);
Dumping Value To Debugbar
It will display values in debug bar.
$arr = [15, TRUE, NULL, 'hello'];
d($arr);
d([2, 4, 6, 8], 'even numbers');
d([1, 3, 5], 'odd numbers');
Dumping Value To Debugbar
It will display values in debug bar.
use Cygnite\Exception\ExceptionHandler;
logMessage("Exception log");
logMessage("Exception log with priority", ExceptionHandler::ERROR); // Sends an email notification
FireLogger
You may wish to log information into Fire logger.
fire_log('Hello World');
Time benchmarking
You may wish to log information into Fire logger.
time_bench('application-running');
$totalElapsed = time_bench('application-running'); //
Read more: timer
Getting Collection
collection([1,2,3]);