Chciałbym wywołać w konsoli akcję, a później wrzucić ją do cronów.
Znalazłem prosty przykład jak wyświetlić coś w konsoli czyli:
namespace Cron\CronBundle\Command; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class GreetCommand extends Command { protected function configure() { $this ->setName('phax:action') ->setDescription('Execute Phax action using command line') ->addArgument('controller', InputArgument::OPTIONAL, 'Controller name', 'help') ->addArgument('action', InputArgument::OPTIONAL, 'Action name', 'default') ->addOption( 'parameters', 'p', InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, 'Parameters to send to the controller' ) ; } protected function execute(InputInterface $input, OutputInterface $output) { $name = $input->getArgument('name'); if ($name) { $text = 'Hellosa '.$name; } else { $text = 'Helloaaa'; } if ($input->getOption('yell')) { } $output->writeln($text); } }
#!/usr/bin/env php <?php // application.php require __DIR__.'/vendor/autoload.php'; use Cron\CronBundle\Command\GreetCommand; use Symfony\Component\Console\Application; $application = new Application(); $application->add(new GreetCommand()); $application->run();
$ php application.php demo:greet Fabien
Ale teraz nie wiem jak zrobić aby wywołać np. akcję z Cron\CronBundle\Controller\DefaultController->indexAction()
Prosiłbym o jakąś pomoc i wskazówki