PHP code example of dpeuscher / alfred-symfony-tools

1. Go to this page and download the library: Download dpeuscher/alfred-symfony-tools library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dpeuscher / alfred-symfony-tools example snippets


    protected function configure()
    {
        $this
            ->setName('commandname')
            ->addArgument('arg1', InputArgument::OPTIONAL, ['option1', 'option2'])
            ->addArgument('arg2', InputArgument::OPTIONAL, 
                ['shortoption2.1' => 'longoption2.1', 'shortoption2.2' => 'longoption2.2'])
            ->addArgument('arg3', InputArgument::OPTIONAL, ['option3.1'], true)
            ->addArgument('arg4', InputArgument::OPTIONAL)
            ->addArgument('arg5', InputArgument::OPTIONAL + InputArgument::IS_ARRAY);
    }

    protected function initialize(InputInterface $input, OutputInterface $output)
    {
        $options4 = $this->getContainer()->getParameter('options4');
        $this->addArgumentsAllowedValues('arg4', $options4);
    }

    protected function initialize(InputInterface $input, OutputInterface $output)
    {
        // ...
        $this->addInputHandler(['arg1', 'arg2'], function ($arguments) {
            if ($arguments['arg1'] === 'option1') {
                foreach ($arguments['genericResults'] as $result) {
                    $result->setTitle(ucwords($result->getTitle()));
                }
            }
        });
    }



$root = dirname(__DIR__);

return [
    'pathToEnv'  => $root . '/.env',
    'backupPath' => $root . '/var/backups/',
];

if (!isset($alfredArgv)) {
    $alfredArgv = implode(' ', $argv);
}

$_SERVER['argv'] = explode(' ', iconv("UTF-8-MAC", "UTF-8", $alfredArgv));

$argv = $_SERVER['argv'];

$alfredArgv = "bin/console command {query}";


    protected function initialize(InputInterface $input, OutputInterface $output)
    {
        $this->workflowHelper->variable('var', 'value');
    }

echo $_ENV['var'];

$alfredArgv = "bin/console config {query}";


$alfredArgv = "bin/console config -x {query}";

bash
echo ${var}