PHP code example of fusic / encount

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

    

fusic / encount example snippets


// config/bootstrap.php


use Encount\Error\EncountErrorTrap;
use Encount\Error\EncountExceptionTrap;

/*
 * Register application error and exception handlers.
 */
// (new ErrorTrap(Configure::read('Error')))->register();
// (new ExceptionTrap(Configure::read('Error')))->register();
(new EncountErrorTrap(Configure::read('Error')))->register();
(new EncountExceptionTrap(Configure::read('Error')))->register();

// src/Application.php


use Encount\Middleware\EncountErrorHandlerMiddleware;

$middleware
    // ->add(new ErrorHandlerMiddleware(Configure::read('Error'), $this))
    ->add(new EncountErrorHandlerMiddleware(Configure::read('Error'), $this))

// config/app.php


return [

-snip-

    'Error' => [
        'errorLevel' => E_ALL & ~E_DEPRECATED,
        'skipLog' => [],
        'log' => true,
        'trace' => true,
        'encount' => [
            'force' => false,
            'sender' => [
                'Encount.Mail',
            ],
            // ignore ex)
            // 'deny' => [
            //     'exception' => [
            //         '\Cake\Http\Exception\MissingControllerException', // 404
            //         '\Cake\Http\Exception\MethodNotAllowedException', // 404
            //         '\Cake\Http\Exception\ForbiddenException', // isAuthorized
            //         '\Cake\Controller\Exception\MissingActionException', // 404
            //         '\Cake\Datasource\Exception\RecordNotFoundException', // notFoundRecored
            //     ],
            // ],
        ],
    ],

-snip-

    'EmailTransport' => [
        'default' => [
        ],
        // Encount Email config
        'encount' => [
            'className' => SmtpTransport::class,
            'port' => xxx,
            'timeout' => xx,
            'host' => 'xxxxxxxxxxxxxxxxx',
            'username' => '[email protected]',
            'password' => 'xxxxxxxx',
            'log' => true,
            'tls' => true,
        ],
    ],

    'Email' => [
        'default' => [
        ],
        // Encount Email config
        'error' => [
            'transport' => 'encount',
            'from' => '[email protected]',
            'to' => '[email protected]',
            'charset' => 'utf-8',
            'headerCharset' => 'utf-8',
        ],
    ],

-snip-

];