PHP code example of rarths / csparkles

1. Go to this page and download the library: Download rarths/csparkles 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/ */

    

rarths / csparkles example snippets


$di->set('sparkles', function () use ($di) {
    $sparkles = new \Rarths\Sparkles\CSparkles();
    $sparkles->setDI($di);
    return $sparkles;
});

$di->set('sparkles', function () use ($di) {
    $sparkles = new \Rarths\Sparkles\CSparkles(array(
    	'error' 	=> 'custom-error-message-class',
    	'success' 	=> 'custom-success-message-class',
    	'notice' 	=> 'custom-notice-message-class',
	));
    $sparkles->setDI($di);
    return $sparkles;
});

$app->sparkles->flash('error', 'Oh sparkles! You have to watch out somewhere..');

$messages = $this->sparkles->output();
if (!empty($messages)) {
	echo '<div class="top-flash">';
	foreach ($messages as $key => $message) {
		echo $message;
	}
	echo '</div>';
}