A simple to use PHP class to work with the Laravel Envoyer API
- PHP ^7.4
- PHP ext-json
The preferred method of installation is to use composer:
$ composer require juststeveking/laravel-envoyer-sdk
To work with this package, firstly you must have a Laravel Envoyer account, and secondly you must create an API token through Laravel Envoyer itself.
You create a simple SDK like so:
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
Once you have $envoyer
set up, you can now start to work with the resources through the API:
The simple way to manage envoyer projects through the SDK:
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->projects->all();
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->projects->save([
'name' => 'SDK test',
'provider' => 'github', // bitbucket, github, gitlab, gitlab-self
'type' => 'laravel-5', // laravel-5. laravel-4, other
'repository' => 'laravel/laravel',
'branch' => 'master'
]);
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->projects->find('id-of-project');
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->projects->modify('id-of-project', [
'name' => 'Project name update through SDK',
]);
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->projects->delete('id-of-project');
The simple way to manage envoyer servers through the SDK:
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->servers->on('id-of-project')->all();
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->servers->on('id-of-project')->create([
'name' => 'Server Name',
'connectAs' => 'forge',
'host' => 'ip-address-here',
'phpVersion' => 'php80' // php80, php74, php73, php72, php71, php70, php56
]);
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->servers->on('id-of-project')->first('id-of-your-server');
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->servers->on('id-of-project')->modify('id-of-your-server', [
'name' => 'SDK Server'
]);
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->servers->on('id-of-project')->remove('id-of-your-server');
The simple way to manage project environments through the SDK:
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->environments->on('id-of-project')->key('1234')->all();
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->environments->on('id-of-project')->key('1234')->servers();
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->environments->on('id-of-project')
->key('1234')->onServer(1, 2, 3)
->put('test=api', 'another=value')
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->environments->on('id-of-project')->key('new-env-key')->reset('new-key');
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->actions->all();
The simple way to manage action hooks for a project through the SDK:
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->hooks->on('id-of-project')->all();
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->hooks->on('id-of-project')->create([
'name' => 'list',
'script' => 'll',
'runAs' => 'forge',
'actionId' => 'id-of-action',
'timing' => 'after',
'servers' => ['id-of-server', 'another-id-of-a-server']
]);
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->hooks->on('id-of-project')->first('id-of-hook');
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->hooks->on('id-of-project')->modify('id-of-hook', [
'name' => 'list files and directories'
]);
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->hooks->on('id-of-project')->remove('id-of-hook');
The simple way to manage project deployments through the SDK:
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->deployments->on('id-of-project')->all();
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->deployments->on('id-of-project')->deploy();
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->deployments->on('id-of-project')->first('id-of-deployment');
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->deployments->on('id-of-project')->cancel('id-of-deployment');
The simple way to manage project collaborators through the SDK
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->collaborators->on('id-of-project')->all();
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->collaborators->on('id-of-project')->invite([
'email' => '[email protected]'
]);
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->collaborators->on('id-of-project')->first('id-of-collaborator');
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->collaborators->on('id-of-project')->remove('id-of-collaborator');
The simple way to manage project notifications through the SDK:
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->notifications->on('id-of-project')->all();
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
// Create an Email Notification
$envoyer->notifications->on('id-of-project')->create([
'name' => 'Notification Name',
'type' => 'email', // email, discord, slack, teams
'email_address' => '[email protected]'
]);
// Create a Discord Notification
$envoyer->notifications->on('id-of-project')->create([
'name' => 'Notification Name',
'type' => 'discord', // email, discord, slack, teams
'discord_webhook' => 'url-of-webhook'
]);
// Create a Slack Notification
$envoyer->notifications->on('id-of-project')->create([
'name' => 'Notification Name',
'type' => 'slack', // email, discord, slack, teams
'slack_webhook' => 'url-of-webhook'
]);
// Create a Teams Notification
$envoyer->notifications->on('id-of-project')->create([
'name' => 'Notification Name',
'type' => 'teams', // email, discord, slack, teams
'teams_webhook' => 'url-of-webhook'
]);
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->notifications->on('id-of-project')->first('id-of-notification');
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->notifications->on('id-of-project')->modify('id-of-notification', [
'name' => 'Send Someone an email',
'type' => 'email',
'email_address' => '[email protected]'
]);
use JustSteveKing\Laravel\Envoyer\SDK\Envoyer;
$envoyer = Envoyer::illuminate(
API_TOKEN_HERE,
'https://envoyer.io/' // this is optional as is the default
);
$envoyer->notifications->on('id-of-project')->remove('id-of-notification');