PHP code example of orchestra / messages

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

    

orchestra / messages example snippets


'providers' => [

    // ...

    Orchestra\Messages\MessagesServiceProvider::class,
],

'aliases' => [

    // ...

    'Messages' => Orchestra\Support\Facades\Messages::class,
],

Messages::add('success', 'A successful message');

Messages::add('success', 'A successful message')
    ->add('error', 'Some error');

Messages::extend(function ($message) {
    $message->add('info', 'Read-only mode');
});



$message = Messages::copy();

if ($message instanceof Orchestra\Messages\MessageBag) {
    $message->setFormat('<div class="alert alert-:key">:message</div>');

    foreach (['error', 'info', 'success'] as $key) {
        if ($message->has($key)) {
            echo implode('', $message->get($key));
        }
    }
}