Skip to content

How to create a package

Robert Deutz edited this page Aug 13, 2018 · 2 revisions
  1. Create a directory src/Task/Dog

  2. Create a Task.php in the directory

namespace JoomlaRobo\Task\Dog;

trait Tasks
{
    /**
     * Do something
     *
     * @param  string $parameter
     *
     * @return JoomlaRobo\Task\Dog
     */
    protected function taskDoSomething($parameter)
    {
        return $this->task(DogDoSomething::class, $parameter);
    }
}
  1. Create a file DogDoSomething.php
namespace JoomlaRobo\Task\Test;

/**
 * Fun with a Dog 
 *
 * @since 0.1.0
 */
class DogDoSomething extends JoomlaTask
{
	/**
	 * Do Something
	 */
	public function run()
	{
		$this->printTaskInfo('We are doing something');
		// Execute the task
		$this->collectionBuilder()->taskExec()->run();
	}
}
  1. Create a file src/Robo/Plugin/Commands/DogCommands.php
namespace JoomlaRobo\Robo\Plugin\Commands;

class DogCommands extends \Robo\Tasks
{
    use \JoomlaRobo\Task\Scaffold\Tasks;

    /**
     * Do Dog Command 
     * 
     * @command Dog:DoSometing
     * 
     * @param string $param
     */    
    public function Component($param) 
    {
        $this->taskDogDoSomething($param)
            ->run();
    }
}
Clone this wiki locally