Skip to content

Instantly share code, notes, and snippets.

@pixelbrackets
Last active January 16, 2020 10:37
Show Gist options
  • Save pixelbrackets/b34bdd42d3301c1523b1ebb46f04d5e1 to your computer and use it in GitHub Desktop.
Save pixelbrackets/b34bdd42d3301c1523b1ebb46f04d5e1 to your computer and use it in GitHub Desktop.
Robo example app
<?php
require __DIR__ . '/vendor/autoload.php';
// Use Robo in standalone app
// https://robo.li/framework/#robo-as-a-framework
//
// - Install Robo `composer require consolidation/robo:^1.0`
// - Run app `php robo-example-app.php`
class RoboFile extends \Robo\Tasks
{
protected function updateFiles() {
$collection = $this->collectionBuilder();
$collection->taskFilesystemStack()
->mkdir('g')
->touch('g/g.txt');
$collection->taskFilesystemStack()
->mkdir('g/h')
->touch('g/h/h.txt');
$collection->taskFilesystemStack()
->mkdir('g/h/i/c')
->touch('g/h/i/i.txt');
$collection->rollback(
$this->taskDeleteDir('g')
);
$collection->run();
}
/**
* Build task
*
* @param array $options
* @option $title Title of the app
*/
public function build(array $options = ['title|t' => 'example'])
{
$this->say($options['title'] . ' app');
$temporaryPath = $this->_tmpDir();
$this->say($temporaryPath);
//echo $temporaryPath;
$this->updateFiles();
}
}
$runner = new \Robo\Runner(RoboFile::class);
$statusCode = $runner->execute([null, 'build', '-t', 'acme']); // = ./robo.phar build -t acme
// Hint: Add »-q« to mute Robo
exit($statusCode);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment