PHP library for creating console messages

1.1.1 2021-07-28 16:53 UTC



PHP Messenger provides a suite of routine which can be used in CLI based applications, providing a simple consistent interface, taking care of all the colorizing for you.


Using with Laravel Commands and Laravel-Zero

In addition, PHP Messenger can also be used with CLI applications created with Laravel Commands or Laravel-Zero, using the Laravel facades interface.


composer require codedungeon/php-messenger

Laravel Configuration

Laravel before 5.5 registration

  • Registering Service Provider

    Modify config/app.php and add the Service Provide

        'providers' => [
  • Registering Facades

    Modify config/app/php and add the Facades to the aliases section

         'aliases' => [
             'Messenger' => Codedungeon\PHPMessenger\MessengerServiceProvider::class,

Laravel 5.5 and greater

When installing into a Laravel based project, it will use the auto discover system available with Laravel 5.5 or greater.

Laravel Zero Configuration

  • Register Service Provider

    Modify config/app.php providers section

     	'providers' => [
  • Create desired command, and use as follows

     	// add use statement
     	use Codedungeon\PHPMessenger\Facades\Messenger;
     	// handle method
     	public function handle()
     		echo PHP_EOL;
     		$msg = "PHP Messenger v" . Messenger::version();
     		Messenger::info("-- Using Laravel Package (Facades)");

Using in non-Laravel applications


require __DIR__ . '/vendor/autoload.php';

use Codedungeon\PHPMessenger\Messenger;

$messenger = new Messenger();

$messenger->success("Success Message w/ Label"," SUCCESS ");
$messenger->info("Information Message");


Messenger Signature

All messenger methods use the same method signature as follows

Parameter Type Description
message string Desired message to display in console
label string Optional label message, if supplied the label will appear first, followed by message

Messenger Methods

Messenger::log(msg:string, [label:string - optional])

Messenger::info(msg:string, [label:string - optional])

Messenger::debug(msg:string, [label:string - optional])

Messenger::critical(msg:string, [label:string - optional])

Messenger::error(msg:string, [label:string - optional])

Messenger::success(msg:string, [label:string - optional])

Messenger::warning(msg:string, [label:string - optional])

Messenger::warn(msg:string, [label:string - optional])

Messenger::important(msg:string, [label:string - optional])

Messenger::status(msg:string, [label:string - optional])

Messenger::notice(msg:string, [label:string - optional])

Messenger::note(msg:string, [label:string - optional])

Messenger::version() -> returns current package version


Copyright © 2019-2020 Mike Erickson Released under the MIT license


PHP Messenger written by Mike Erickson


Twitter: @codedungeon