PHP code example of assimtech / tempo

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

    

assimtech / tempo example snippets




use Assimtech\Tempo;
use MyProject\Tempo\Command;

// Infrastructure
$infrastructureLoader = Tempo\Factory\InfrastructureLoaderFactory::create();
$infrastructure = $infrastructureLoader->load(__DIR__ . '/infrastructure.yml');

// Commands
$definition = new Tempo\Definition();
foreach ($infrastructure->getEnvironments() as $env) {
    $definition->addCommand(new Command\WhereAmI($env));
}

return $definition;



namespace MyProject\Tempo\Command;

use Assimtech\Sysexits;
use Assimtech\Tempo\Command\AbstractCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class WhereAmI extends AbstractCommand
{
    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        foreach ($this->env->getNodes() as $node) {
            $output->write("<comment>Checking uname of $node: </comment>");
            $uname = $node->run('uname -a');
            $output->writeln("<info>$uname</info>");
        }

        return Sysexits::EX_OK;
    }
}