tzb/sendy-bundle

Symfony bundle that integrates SendyPHP library from Jacob Bennett: https://github.com/JacobBennett/SendyPHP.

Installs: 122

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 1

Type:symfony-bundle

2.0.0 2022-04-01 14:13 UTC

This package is not auto-updated.

Last update: 2024-04-20 14:41:07 UTC


README

Scrutinizer Code Quality Build Status

This bundle is used to integrate the SendyPHP class from Jacob Bennett into a symfony2 project.

Installation

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

$ composer require jkabat/sendy-bundle

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 2: Enable the Bundle

Then, enable the bundle by adding the following line in the app/AppKernel.php file of your project:

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            // ...

            new Sendy\SendyBundle\SendyBundle(),
        ];

        // ...
    }

    // ...
}

Step 3: Configure sendy_manager Service

# app/config/config.yml
sendy:
    api_key: sendy_api_key
    api_host: https://sendy.installation.url
    list_id: default_list_id

Usage

Get count of total active subscribers for default list:

// get service
$sendy = $this->container->get('sendy.sendy_manager');
$count = $sendy->getSubscriberCount();

Get count of total active subscribers for other list:

$sendy = $this->container->get('sendy.sendy_manager');
$count = $sendy->getSubscriberCount('other_list_id');

Get status of subscriber identified by e-mail:

$sendy = $this->container->get('sendy.sendy_manager');
$status = $sendy->getSubscriberStatus('email@example.com');

Subscribe user to default list (other list id can be used as third parameter):

$sendy = $this->container->get('sendy.sendy_manager');
$status = $sendy->subscribe('Name', 'email@example.com');

Unsubscribe user from default list (other list id can be used as second parameter):

$sendy = $this->container->get('sendy.sendy_manager');
$status = $sendy->unsubscribe('email@example.com');