tobento/app-message

1.0.0 2024-03-01 18:31 UTC

This package is auto-updated.

Last update: 2024-04-30 18:50:13 UTC


README

Message manager for the app.

Table of Contents

Getting Started

Add the latest version of the app message project running this command.

composer require tobento/app-message

Requirements

  • PHP 8.0 or greater

Documentation

App

Check out the App Skeleton if you are using the skeleton.

You may also check out the App to learn more about the app in general.

Message Boot

The message boot does the following:

  • configures the messages factory
use Tobento\App\AppFactory;
use Tobento\Service\Message\MessagesFactoryInterface;

// Create the app
$app = (new AppFactory())->createApp();

// Add directories:
$app->dirs()
    ->dir(realpath(__DIR__.'/../'), 'root')
    ->dir(realpath(__DIR__.'/../app/'), 'app')
    ->dir($app->dir('app').'config', 'config', group: 'config')
    ->dir($app->dir('root').'public', 'public')
    ->dir($app->dir('root').'vendor', 'vendor');

// Adding boots
$app->boot(\Tobento\App\Message\Boot\Message::class);
$app->booting();

// Implemented interfaces:
$messagesFactory = $app->get(MessagesFactoryInterface::class);

// Run the app
$app->run();

Creating Messages

Check out the Message Service - Messages Factory section to learn more about creating messages.

Translating Messages

Simply, install the App Translation bundle and boot the \Tobento\App\Translation\Boot\Translation::class:

composer require tobento/app-translation
use Tobento\App\AppFactory;

// Create the app
$app = (new AppFactory())->createApp();

// Add directories:
$app->dirs()
    ->dir(realpath(__DIR__.'/../'), 'root')
    ->dir(realpath(__DIR__.'/../app/'), 'app')
    ->dir($app->dir('app').'config', 'config', group: 'config')
    ->dir($app->dir('root').'public', 'public')
    ->dir($app->dir('root').'vendor', 'vendor');
    
// Adding boots
$app->boot(\Tobento\App\Translation\Boot\Translation::class);
$app->boot(\Tobento\App\Message\Boot\Message::class);

// Run the app
$app->run();

Messages will be translated based on the Configured Translator Locale.

The configured Message Translator Modifier uses the * as resource name. Check out the Translation Resources and Translation Files Resources to learn more about it.

Check out the Add Translation or Migrate Translation section to learn how to add or migrate translations.

Logging Messages

Simply, install the App Logging bundle and boot the \Tobento\App\Logging\Boot\Logging::class:

composer require tobento/app-translation
use Tobento\App\AppFactory;

// Create the app
$app = (new AppFactory())->createApp();

// Add directories:
$app->dirs()
    ->dir(realpath(__DIR__.'/../'), 'root')
    ->dir(realpath(__DIR__.'/../app/'), 'app')
    ->dir($app->dir('app').'config', 'config', group: 'config')
    ->dir($app->dir('root').'public', 'public')
    ->dir($app->dir('root').'vendor', 'vendor');
    
// Adding boots
$app->boot(\Tobento\App\Logging\Boot\Logging::class);
$app->boot(\Tobento\App\Message\Boot\Message::class);

// Run the app
$app->run();

On the App Logging Config file define the logger used for messages:

/*
|--------------------------------------------------------------------------
| Aliases
|--------------------------------------------------------------------------
*/

'aliases' => [
    'messages' => 'daily',
],

Credits