Development Tasks
Changelog
Helps to manage changelog file. Creates or updates changelog.md file with recent changes in current version.
<?php
$version = "0.1.0";
$this->taskChangelog()
->version($version)
->change("released to github")
->run();
?>Changes can be asked from Console
<?php
$this->taskChangelog()
->version($version)
->askForChanges()
->run();
?>filename($filename)*param string$filenamesetBody($body)Sets the changelog body text.setHeader($header)*param string$headerlog($item)*param string$itemanchor($anchor)*param string$anchorversion($version)*param string$versionchanges(array $data)*param array$datachange($change)*param string$changegetChanges()@return arrayprocessLogRow($i)*param string$isetOutput($output)Sets the Console Output.
GenerateMarkdownDoc
Simple documentation generator from source files. Takes classes, properties and methods with their docblocks and writes down a markdown file.
<?php
$this->taskGenDoc('models.md')
->docClass('Model\User') // take class Model\User
->docClass('Model\Post') // take class Model\Post
->filterMethods(function(\ReflectionMethod $r) {
return $r->isPublic() or $r->isProtected(); // process public and protected methods
})->processClass(function(\ReflectionClass $r, $text) {
return "Class ".$r->getName()."\n\n$text\n\n###Methods\n";
})->run();By default this task generates a documentation for each public method of a class, interface or trait. It combines method signature with a docblock. Both can be post-processed.
<?php
$this->taskGenDoc('models.md')
->docClass('Model\User')
->processClassSignature(false) // false can be passed to not include class signature
->processClassDocBlock(function(\ReflectionClass $r, $text) {
return "[This is part of application model]\n" . $text;
})->processMethodSignature(function(\ReflectionMethod $r, $text) {
return "#### {$r->name}()";
})->processMethodDocBlock(function(\ReflectionMethod $r, $text) {
return strpos($r->name, 'save')===0 ? "[Saves to the database]\n" . $text : $text;
})->run();docClass($item)Put a class you want to be documented.filterMethods($filterMethods)Using a callback function filter out methods that won't be documented.filterClasses($filterClasses)Using a callback function filter out classes that won't be documented.filterProperties($filterProperties)Using a callback function filter out properties that won't be documented.processClass($processClass)Post-process class documentation.processClassSignature($processClassSignature)Post-process class signature. Provide false to skip.processClassDocBlock($processClassDocBlock)Post-process class docblock contents. Provide false to skip.processMethod($processMethod)Post-process method documentation. Provide false to skip.processMethodSignature($processMethodSignature)Post-process method signature. Provide false to skip.processMethodDocBlock($processMethodDocBlock)Post-process method docblock contents. Provide false to skip.processProperty($processProperty)Post-process property documentation. Provide false to skip.processPropertySignature($processPropertySignature)Post-process property signature. Provide false to skip.processPropertyDocBlock($processPropertyDocBlock)Post-process property docblock contents. Provide false to skip.reorder($reorder)Use a function to reorder classes.reorderMethods($reorderMethods)Use a function to reorder methods in class.reorderProperties($reorderProperties)*param callable$reorderPropertiesfilename($filename)*param string$filenameprepend($prepend)Inserts text at the beginning of markdown file.append($append)Inserts text at the end of markdown file.text($text)*param string$texttextForClass($item)*param string$itemsetOutput($output)Sets the Console Output.
Generate
Generate a Robo Task that is a wrapper around an existing class.
<?php
$this->taskGenerateTask('Symfony\Component\Filesystem\Filesystem', 'FilesystemStack')
->run();setOutput($output)Sets the Console Output.
GitHubRelease
Publishes new GitHub release.
<?php
$this->taskGitHubRelease('0.1.0')
->uri('consolidation-org/Robo')
->description('Add stuff people need.')
->change('Fix #123')
->change('Add frobulation method to all widgets')
->run();
?>tag($tag)*param string$tagdraft($draft)*param bool$draftname($name)*param string$namedescription($description)*param string$descriptionprerelease($prerelease)*param bool$prereleasecomittish($comittish)*param string$comittishappendDescription($description)*param string$descriptionchanges(array $changes)change($change)*param string$changerepo($repo)*param string$repoowner($owner)*param string$owneruri($uri)*param string$uriuser($user)*param string$userpassword($password)*param string$passwordaccessToken($token)*param string$tokensetOutput($output)Sets the Console Output.
OpenBrowser
Opens the default's user browser code inspired from openBrowser() function in https://github.com/composer/composer/blob/master/src/Composer/Command/HomeCommand.php
<?php
// open one browser window
$this->taskOpenBrowser('http://localhost')
->run();
// open two browser windows
$this->taskOpenBrowser([
'http://localhost/mysite',
'http://localhost/mysite2'
])
->run();setOutput($output)Sets the Console Output.
PackPhar
Creates Phar.
<?php
$pharTask = $this->taskPackPhar('package/codecept.phar')
->compress()
->stub('package/stub.php');
$finder = Finder::create()
->name('*.php')
->in('src');
foreach ($finder as $file) {
$pharTask->addFile('src/'.$file->getRelativePathname(), $file->getRealPath());
}
$finder = Finder::create()->files()
->name('*.php')
->in('vendor');
foreach ($finder as $file) {
$pharTask->addStripped('vendor/'.$file->getRelativePathname(), $file->getRealPath());
}
$pharTask->run();
// verify Phar is packed correctly
$code = $this->_exec('php package/codecept.phar');
?>compress($compress = null)*param bool$compressstub($stub)*param string$stubaddStripped($path, $file)*param string$pathaddFile($path, $file)*param string$pathaddFiles($files)*param \Symfony\Component\Finder\SplFileInfo[]$filesexecutable($file)*param string$filesetOutput($output)Sets the Console Output.
PhpServer
Runs PHP server and stops it when task finishes.
<?php
// run server in /public directory
$this->taskServer(8000)
->dir('public')
->run();
// run with IP 0.0.0.0
$this->taskServer(8000)
->host('0.0.0.0')
->run();
// execute server in background
$this->taskServer(8000)
->background()
->run();
?>host($host)*param string$hostdir($path)*param string$pathsimulate($context)setOutput($output)Sets the Console Output.setProcessInput($input)Pass an input to the process. Can be resource created with fopen() or stringarg($arg)Pass argument to executable. Its value will be automatically escaped.args($args)Pass methods parameters as arguments to executable. Argument valuesrawArg($arg)Pass the provided string in its raw (as provided) form as an argument to executable.option($option, $value = null, $separator = null)Pass option to executable. Options are prefixed with--, value can be provided in second parameter.options(array $options, $separator = null)Pass multiple options to executable. The associative array containsoptionList($option, $value = null, $separator = null)Pass an option with multiple values to executable. Value can be a string or array.
SemVer
Helps to maintain .semver file.
<?php
$this->taskSemVer('.semver')
->increment()
->run();
?>__toString()@return stringversion($version)*param string$versionsetFormat($format)*param string$formatsetMetadataSeparator($separator)*param string$separatorsetPrereleaseSeparator($separator)*param string$separatorincrement($what = null)*param string$whatprerelease($tag = null)*param string$tagmetadata($data)*param array|string$data