Created
November 26, 2019 01:27
-
-
Save andreia/65ab72de782352b0f9172b562765cf07 to your computer and use it in GitHub Desktop.
A Symfony Command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // src/Command/SomeCommand.php | |
| namespace App\Command; | |
| use Symfony\Component\Console\Command\Command; | |
| use Symfony\Component\Console\Input\InputInterface; | |
| use Symfony\Component\Console\Output\OutputInterface; | |
| class SomeCommand extends Command | |
| { | |
| // the name of the command (the part after "bin/console") | |
| protected static $defaultName = 'app:some-command'; | |
| private $projectRootDir; | |
| public function __construct($projectRootDir) | |
| { | |
| $this->projectRootDir = $projectRootDir; | |
| parent::__construct(); | |
| } | |
| protected function configure() | |
| { | |
| // ... | |
| } | |
| protected function execute(InputInterface $input, OutputInterface $output) | |
| { | |
| // ... | |
| $output->writeln("The project's root directory is: " . $this->projectRootDir); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment