Php Symfony Cron运行操作
我有symfony2.6.11我使用cron,我需要运行一些脚本Php Symfony Cron运行操作,php,symfony,cron,Php,Symfony,Cron,我有symfony2.6.11我使用cron,我需要运行一些脚本 $all_developer = $em->getRepository('ArtelProfileBundle:Developer')->findAll(); foreach ($all_developer as $session_developer) { //some logic } 我知道如何运行应用程序/控制台“somne comand”,但如果我需要运行一些代码,我不知道这些代码如何运行。 帮助如何在
$all_developer = $em->getRepository('ArtelProfileBundle:Developer')->findAll();
foreach ($all_developer as $session_developer) {
//some logic
}
我知道如何运行应用程序/控制台“somne comand”,但如果我需要运行一些代码,我不知道这些代码如何运行。
帮助如何在应用程序/控制台或任何解决方案中添加此代码???您可以在此处看到命令示例()
<?php
namespace Application\CommandBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\ORM\EntityManager;
/**
* Class testCommand
* @package Application\CommandBundle\Command
*/
class TestCommand extends ContainerAwareCommand
{
/**
* Configuration of the command
*/
protected function configure()
{
$this
->setName('command:do:something')
->setDescription('This command does something');
}
protected function initialize(InputInterface $input, OutputInterface $output)
{
}
/**
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
* @return null|int null or 0 if everything went fine, or an error code
*/
protected function execute(InputInterface $inputInterface, OutputInterface $outputInterface)
{
$outputInterface->writeln(
'This command does something <info>' . $inputInterface->getOption('env') . '</info> environment'
);
$this->getContainer()->get('application_command.test')->doSomething();
$outputInterface->writeln('Done');
}
}
$this->getContainer()->get('application_command.test')->doSomething();