Skip to content

Instantly share code, notes, and snippets.

@jamescowie
Last active December 22, 2015 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamescowie/679974a04816b2bef206 to your computer and use it in GitHub Desktop.
Save jamescowie/679974a04816b2bef206 to your computer and use it in GitHub Desktop.
Magento 2 MageCasts CLI setup
# Attach to docker container
docker exec -i -t 75975d676f01 bash
# PHPSPec in composer
"phpspec/phpspec" : "2.*"
# PHPSpec configuration
suites:
default:
src_path: 'app/code'
formatter.name: pretty
# config.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="PocketGuide_Generators" setup_version="0.0.1"/>
</config>
# di.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<type name="Magento\Framework\Console\CommandList">
<arguments>
<argument name="commands" xsi:type="array">
<item name="moduleCommand" xsi:type="object">PocketGuide\Generators\Commands\GeneratorCommand</item>
</argument>
</arguments>
</type>
</config>
# Commands/GeneratorCommand
<?php
namespace PocketGuide\Generators\Commands;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Command\Command;
class GeneratorCommand extends Command
{
/** @var \PocketGuide\Generators\Model\ModuleFolderGenerator $generator */
private $generator;
/**
* @param \PocketGuide\Generators\Model\ModuleFolderGenerator $generator
*/
public function __construct(Generator $generator)
{
$this->generator = $generator;
parent::__construct();
}
protected function configure()
{
$this->setName('generate:module');
$this->setDescription('Build a magento 2 module from the command line');
$this->addArgument(
'name',
InputArgument::REQUIRED,
'Module Name ( Test/Module/ ) '
);
parent::configure();
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->generator->make($input->getArgument('name'));
$output->writeln("Module folder created");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment