Download the PHP package cymapgt/notifier without Composer

On this page you can find all versions of the php package cymapgt/notifier. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package notifier

notifier

Notifier interface that can be used to encapsulate 3rd party communication packages using media like email, sms, chat, messengers, voip

The notifier namespace contains libraries that implement the Notifier Interface.

This interface provides a standard set of common functions for sending communications. This can be email communications or sms communications.

For a detailed documentation on the Notifier Interface, review the Notifier API.

Usage details are provided below

Usage

1 Sending Email using SwiftMailer

1.1 Prepare your Autoloader

//configure the SMTP transport (wasteful but use in proto :/

// Create the Transport
$swiftMailerTransport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 587, 'tls')
    ->setUsername('[email protected]')
    ->setPassword('smtppasswordhere');

1.2 Edit Your PHP Script

1.2.1 Configure your SMTP configuration array

These settings can be pulled from database or hard coded. User the same smtp user and password that you used to configure the SwiftMailer transport in the previous section

$configuration = array (
    'EMAIL_CLIENT'          => 'SwiftMailer',
    'USERNAME'              => '[email protected]',
    'PASSWORD'              => 'smtppasswordhere',
    'HOST'                  => 'smtp.gmail.com',
    'IS_SMTP'               => true,
    'SMTP_DEBUG'            => 2,
    'SMTP_AUTH'             => true,
    'PORT'                  => 587,
    'SMTP_SECURE'           => 'tls',
    'LINE_ENDING'           => '\n', 
    'CHARSET'               => 'utf-8',
    'RETURN_PATH'           => '[email protected]',
    'EMAIL_FROM'            => 'smtppasswordhere',
    'EMAIL_FROM_NAME'       => 'Cyril Ogana',
    'WORD_WRAP'             => 80,
    'IS_HTML'               => true,
    "USE_ANTIFLOOD"         => false,
    "ANTIFLOOD_FREQUENCY_MAILS"   => null,
    "ANTIFLOOD_FREQUENCY_SECONDS"   => null,
    "USE_THROTTLER"         => false,
    "THROTTLER_MAILS_PER_MINUTE" => null,
    "THROTTLER_BYTES_PER_MINUTE" => null        
);

1.2.2 Build your Notifier Class and Send the messages

//declare namespace usage
use cymapgt\core\utility\notifier\NotifierEmailSwiftMailerService;

//create notifier object. The swiftMailerTransport object we pass to it is the one we created in autoloader
$notifierObj = new NotifierEmailSwiftMailerService($swiftMailerTransport);

//our message is in the form of an array
$message = array (
   "TO" => array(
               array (
                   "name"  => "Cyril Ogana",
                   "email" => "[email protected]"
               )
           ),
    "SUBJECT"     =>"MY MAIL",
    "MSG_HTML"    => "Test Notifier 1:)",
    "ATTACHMENTS" => array(
         "imageAttachment" => "c:/User/Image1.jpg"
    )
);

//load our message to the notifier
$notifierObj->setMessage($message);

//send all messages
$notifierObj->sendMessagesAll(array()); 

2 Sending SMS using AfricasTalking

2.1 Edit Your PHP Script

2.2.1 Configure your AfricasTalking configuration array

These settings can be pulled from database or hard coded.

$configuration = array(
            "SMS_CLIENT"      => "AfricasTalking",
            "USERNAME"        => "SMSUSER",
            "PASSWORD"        => "smsApiKeyHere",
            "APIKEY"          => "",
            "IS_API"          => true,
            "IS_BEHIND_PROXY" => false,
            "PROXY_AUTH"      => -1,
            "PROXY_TYPE"      => -1,
            "PROXY_SERVER"    => "",
            "PROXY_LOGIN"     => "",
            "MAX_CHARS"       => 140,
            "SMS_FROM_NAME"   => "SMSUSER"
        );

2.2.2 Build your Notifier Class and Send the messages

Notice that configuration and message building is what is different. Details of configuring the authhentication, sending and receiving details of communications are abstracted away by the Notifier Interface

//declare namespace usage
use cymapgt\core\utility\notifier\NotifierSmsAfricasTalkingService;

/*create notifier object for africas talking. If you are behind a proxy, the
 *second parameter should be true, and your configuration array should contain
 *the proxy server settings
 */
$notifierObj = new NotifierSmsAfricasTalkingService($configuration, false);

//our message is in the form of an array
$message = array (
   "RECIPIENTS" => array(
       "+254723712233",
       "+254720123456",
       "+254721000999"
    ),
    "MESSAGE"     =>"MY TEST SMS :)"
);

//load our message to the notifier
$notifierObj->setMessage($message);

//send all the SMS
$notifierObj->sendMessagesAll(array());

Testing

PHPUnit Tests are provided with the package

Contribute

License

BSD-3 CLAUSE


All versions of notifier with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2.0
swiftmailer/swiftmailer Version ^6.0.0
phpmailer/phpmailer Version ~6.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package cymapgt/notifier contains the following files

Loading the files please wait ....