1. Go to this page and download the library: Download kijtra/toss library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kijtra / toss example snippets
composer.phar
use \Kijtra\Toss;
$toss = new Toss;
// ... something ...
$toss->error('Oops!');
// ... something ...
if ($toss->hasError()) {
echo $toss->getMessage(); // 'Oops!'
}
use \Kijtra\Toss;
Toss::getGlobal()->success('Year!');
// ... something ...
if (Toss::getGlobal()->hasSuccess()) {
echo Toss::getGlobal()->getMessage(); // 'Year!'
}
use \Kijtra\Toss;
$toss = new Toss;
// Add message s
$toss->warning('Warn!');
$toss->info('Information');
// Get LATEST message
$latest = $toss->getMessage();
var_dump($latest->type); // 'info'
var_dump($latest->message); // 'Information'
// Get latest message of type
$messages = $toss->getMessages('warning');
var_dump($messages[0]->type); // 'warning'
var_dump($messages[0]->message); // 'Warn!'
/*
- ATTENTION -
'getMessages()' is need argument.
$messages = $toss->getMessages();
var_dump($messages); // null
*/
use \Kijtra\Toss;
// Add message
$toss = new Toss('You Correct', 'success');
// Get latest message
$latest = $toss->getMessage();
// Sync to Global instance
$latest->toGlobal();
var_dump(Toss::getGlobal()->hasSuccess()); // true
use \Kijtra\Toss;
// Add 'error' type message
$toss = new Toss('Oh no..', 'error');
// Add 'notice' type message
$toss->notice('Really?');
// If message is not empty
if (false === $toss->isNothing()) {
// Clear 'error' type only
$toss->clear('error');
}
var_dump($toss->hasError()); // false
var_dump($toss->hasNotice()); // true
// If message is not empty
if (false === $toss->isNothing()) {
// Clear all message
$toss->clear();
}
var_dump($toss->hasError()); // false
var_dump($toss->hasNotice()); // false
var_dump($toss->isNothing()); // true
use \Kijtra\Toss;
// MUST extending Kijtra\Toss\Type class
class MyType extends Toss\Type
{
// You do not need
}
$toss = new Toss;
$toss->addtype(MyType::class);
// Or $toss->addtype('MyType');
var_dump($toss->getAvailableTypes());
/*
array(
'error',
'warning',
'notice',
'info',
'success',
'invalid',
'valid',
'mytype', <- Added
)
*/
$toss->MyType('My Added Type!');
if ($toss->hasMyType()) {
echo $toss->getMessage(); // 'My Added Type!'
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.