Symfony - call Doctrine in cron tab [duplicate]
This question already has an answer here:
Symfony2 - How to access the service in a custom console command?
2 answers
Hey guys i want to know how can i do a cron tab but that cron tab has to update database so i need
$this->getDoctrine()->getManager()
But for this i need to extend Controller
but i already extend Command
So i there a way to extend both ? Do i have to use sql commands ?Or an other way to update the database with cron tab ?
Here you can find my find and see what i need :
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputInterface;
use SymfonyComponentConsoleOutputOutputInterface;
class MessageController extends Command
protected function configure ()
$this->setName('app:notification');
$this->setDescription("Permet juste d'envoyer les notifications");
$this->setHelp("Je serai affiche si on lance la commande app/console app:notification -h");
public function execute (InputInterface $input, OutputInterface $output)
//HERE I WANT TO DO : $this->getDoctrine()->getManager();
$output->writeln('!');
php symfony cron
marked as duplicate by iainn, u_mulder
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 12 at 14:43
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Symfony2 - How to access the service in a custom console command?
2 answers
Hey guys i want to know how can i do a cron tab but that cron tab has to update database so i need
$this->getDoctrine()->getManager()
But for this i need to extend Controller
but i already extend Command
So i there a way to extend both ? Do i have to use sql commands ?Or an other way to update the database with cron tab ?
Here you can find my find and see what i need :
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputInterface;
use SymfonyComponentConsoleOutputOutputInterface;
class MessageController extends Command
protected function configure ()
$this->setName('app:notification');
$this->setDescription("Permet juste d'envoyer les notifications");
$this->setHelp("Je serai affiche si on lance la commande app/console app:notification -h");
public function execute (InputInterface $input, OutputInterface $output)
//HERE I WANT TO DO : $this->getDoctrine()->getManager();
$output->writeln('!');
php symfony cron
marked as duplicate by iainn, u_mulder
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 12 at 14:43
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
This question already has an answer here:
Symfony2 - How to access the service in a custom console command?
2 answers
Hey guys i want to know how can i do a cron tab but that cron tab has to update database so i need
$this->getDoctrine()->getManager()
But for this i need to extend Controller
but i already extend Command
So i there a way to extend both ? Do i have to use sql commands ?Or an other way to update the database with cron tab ?
Here you can find my find and see what i need :
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputInterface;
use SymfonyComponentConsoleOutputOutputInterface;
class MessageController extends Command
protected function configure ()
$this->setName('app:notification');
$this->setDescription("Permet juste d'envoyer les notifications");
$this->setHelp("Je serai affiche si on lance la commande app/console app:notification -h");
public function execute (InputInterface $input, OutputInterface $output)
//HERE I WANT TO DO : $this->getDoctrine()->getManager();
$output->writeln('!');
php symfony cron
This question already has an answer here:
Symfony2 - How to access the service in a custom console command?
2 answers
Hey guys i want to know how can i do a cron tab but that cron tab has to update database so i need
$this->getDoctrine()->getManager()
But for this i need to extend Controller
but i already extend Command
So i there a way to extend both ? Do i have to use sql commands ?Or an other way to update the database with cron tab ?
Here you can find my find and see what i need :
use SymfonyComponentConsoleCommandCommand;
use SymfonyComponentConsoleInputInputInterface;
use SymfonyComponentConsoleOutputOutputInterface;
class MessageController extends Command
protected function configure ()
$this->setName('app:notification');
$this->setDescription("Permet juste d'envoyer les notifications");
$this->setHelp("Je serai affiche si on lance la commande app/console app:notification -h");
public function execute (InputInterface $input, OutputInterface $output)
//HERE I WANT TO DO : $this->getDoctrine()->getManager();
$output->writeln('!');
This question already has an answer here:
Symfony2 - How to access the service in a custom console command?
2 answers
php symfony cron
php symfony cron
edited Nov 12 at 14:41
asked Nov 12 at 14:38
Luis Rosario
367
367
marked as duplicate by iainn, u_mulder
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 12 at 14:43
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by iainn, u_mulder
StackExchange.ready(function()
if (StackExchange.options.isMobile) return;
$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');
$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();
);
);
);
Nov 12 at 14:43
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
you can extend ContainerAwareCommand instead and use
$this->getContainer()->get('doctrine')->getManager()
i think that works thx :) i can't accept the response for 9min so wait a bit a i put it to valid
– Luis Rosario
Nov 12 at 14:43
thx a lot men :)
– Luis Rosario
Nov 12 at 14:44
Avoid using the container directly in Symfony 4: Better inject the doctrine registry into the constructor via DIC.
– mblaettermann
Nov 12 at 15:09
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
you can extend ContainerAwareCommand instead and use
$this->getContainer()->get('doctrine')->getManager()
i think that works thx :) i can't accept the response for 9min so wait a bit a i put it to valid
– Luis Rosario
Nov 12 at 14:43
thx a lot men :)
– Luis Rosario
Nov 12 at 14:44
Avoid using the container directly in Symfony 4: Better inject the doctrine registry into the constructor via DIC.
– mblaettermann
Nov 12 at 15:09
add a comment |
you can extend ContainerAwareCommand instead and use
$this->getContainer()->get('doctrine')->getManager()
i think that works thx :) i can't accept the response for 9min so wait a bit a i put it to valid
– Luis Rosario
Nov 12 at 14:43
thx a lot men :)
– Luis Rosario
Nov 12 at 14:44
Avoid using the container directly in Symfony 4: Better inject the doctrine registry into the constructor via DIC.
– mblaettermann
Nov 12 at 15:09
add a comment |
you can extend ContainerAwareCommand instead and use
$this->getContainer()->get('doctrine')->getManager()
you can extend ContainerAwareCommand instead and use
$this->getContainer()->get('doctrine')->getManager()
answered Nov 12 at 14:41
Benjamin Lemoine
707
707
i think that works thx :) i can't accept the response for 9min so wait a bit a i put it to valid
– Luis Rosario
Nov 12 at 14:43
thx a lot men :)
– Luis Rosario
Nov 12 at 14:44
Avoid using the container directly in Symfony 4: Better inject the doctrine registry into the constructor via DIC.
– mblaettermann
Nov 12 at 15:09
add a comment |
i think that works thx :) i can't accept the response for 9min so wait a bit a i put it to valid
– Luis Rosario
Nov 12 at 14:43
thx a lot men :)
– Luis Rosario
Nov 12 at 14:44
Avoid using the container directly in Symfony 4: Better inject the doctrine registry into the constructor via DIC.
– mblaettermann
Nov 12 at 15:09
i think that works thx :) i can't accept the response for 9min so wait a bit a i put it to valid
– Luis Rosario
Nov 12 at 14:43
i think that works thx :) i can't accept the response for 9min so wait a bit a i put it to valid
– Luis Rosario
Nov 12 at 14:43
thx a lot men :)
– Luis Rosario
Nov 12 at 14:44
thx a lot men :)
– Luis Rosario
Nov 12 at 14:44
Avoid using the container directly in Symfony 4: Better inject the doctrine registry into the constructor via DIC.
– mblaettermann
Nov 12 at 15:09
Avoid using the container directly in Symfony 4: Better inject the doctrine registry into the constructor via DIC.
– mblaettermann
Nov 12 at 15:09
add a comment |