PHP code example of dekor / devio

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

    

dekor / devio example snippets


#!/usr/bin/env php

Devio, Docker, Env, Http, Notifier, Ssh, SshConnection};
use Dekor\Devio\Channels\Telegram;

Env::load(__DIR__ . '/.env.deploy');   // git-ignored, below

Ssh::addHost('prod', getenv('PROD_HOST'), getenv('PROD_USER'), getenv('PROD_SSH_KEY'), dir: getenv('PROD_DIR'));
Notifier::addChannel('telegram', new Telegram(getenv('TG_TOKEN'), getenv('TG_CHAT')));

Devio::command(name: 'up', description: 'start the dev stack', handler: fn (Args $args) => Docker::compose('up', '-d', ...$args))
    ->command(name: 'art', description: 'artisan', handler: fn (Args $args) => Docker::compose('exec', 'app', 'php', 'artisan', ...$args))->plain()
    ->command(name: 'deploy', description: 'deploy to prod', handler: function () {
        Ssh::to('prod')->run(function (SshConnection $prod) {
            $prod->run('git pull');
            Docker::compose('up', '-d', '--build');      // runs on prod: we are inside its closure
        });
        Http::expect('https://example.com');
        Notifier::success('deployed');
    });

Devio::run();