PHP code example of compenda / sendwithus

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

    

compenda / sendwithus example snippets


use Compenda\SendWithUs\Facades\SendWithUs;
// you can alias this in config/app.php if you like

$emails = SendWithUs::emails();
// we're done here - how easy was that, it just works!

$segments = SendWithUs::get_segments();
// this example is simple, and there are far more methods available

use Compenda\SendWithUs\Facades\SendWithUs;

// the alternative connection is the other example provided in the default config
// let's create a copy ref so we can copy a file to the main connection
$emails = SendWithUs::connection('alternative')->emails();

use Compenda\SendWithUs\Facades\SendWithUs;

// writing this:
$emails = SendWithUs::connection('main')->emails();

// is identical to writing this:
$emails = SendWithUs::emails();

// and is also identical to writing this:
$emails = SendWithUs::connection('main')->emails();

// this is because the main connection is configured to be the default
SendWithUs::getDefaultConnection(); // this will return main

// we can change the default connection
SendWithUs::setDefaultConnection('alternative'); // the default is now alternative

use Compenda\SendWithUs\SendWithUsManager;
use Illuminate\Support\Facades\App; // you probably have this aliased already

class Foo
{
    protected $sendwithus;

    public function __construct(SendWithUsManager $sendwithus)
    {
        $this->sendwithus = $sendwithus;
    }

    public function bar()
    {
        return $this->sendwithus->emails();
    }
}

App::make('Foo')->bar();
bash
$ php artisan vendor:publish