PHP code example of amesplash / campaignmonitor-log

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

    

amesplash / campaignmonitor-log example snippets



declare(strict_types=1);

namespace App;

use CS_REST_Campaigns;
use Psr\Log\LoggerInterface;
use Psr\Container\ContainerInterface;
use Amesplash\CampaignMonitorLog\LogDecorator;

final class MyCampaignMonitorCampaignFactory
{
    public function __invoke(ContainerInterface $container) : CS_REST_Campaigns
    {
        $params = $container->get('params');
        $psr3Logger = $container->get('monolog or any other PSR 3 Logger');

        $defaultContext = [
            'Campaign' => 'Functional Dev',
        ];

        $logDecorator = new LogDecorator($psr3Logger, $defaultContext);

        return new CS_REST_Campaigns(
            $params->get('campaignmonitor.campaign_id'),
            ['api_key' => $params->get('campaignmonitor.api_key')],
            'https',
            CS_REST_LOG_VERBOSE,
            'api.createsend.com',
            $logDecorator
        );
    }
}