Symfony - call Doctrine in cron tab [duplicate]










1















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('!');











share|improve this question















marked as duplicate by iainn, u_mulder php
Users with the  php badge can single-handedly close php questions as duplicates and reopen them as needed.

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.



















    1















    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('!');











    share|improve this question















    marked as duplicate by iainn, u_mulder php
    Users with the  php badge can single-handedly close php questions as duplicates and reopen them as needed.

    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.

















      1












      1








      1








      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('!');











      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 at 14:41

























      asked Nov 12 at 14:38









      Luis Rosario

      367




      367




      marked as duplicate by iainn, u_mulder php
      Users with the  php badge can single-handedly close php questions as duplicates and reopen them as needed.

      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 php
      Users with the  php badge can single-handedly close php questions as duplicates and reopen them as needed.

      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.
























          1 Answer
          1






          active

          oldest

          votes


















          1














          you can extend ContainerAwareCommand instead and use



          $this->getContainer()->get('doctrine')->getManager()





          share|improve this answer




















          • 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

















          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          you can extend ContainerAwareCommand instead and use



          $this->getContainer()->get('doctrine')->getManager()





          share|improve this answer




















          • 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















          1














          you can extend ContainerAwareCommand instead and use



          $this->getContainer()->get('doctrine')->getManager()





          share|improve this answer




















          • 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













          1












          1








          1






          you can extend ContainerAwareCommand instead and use



          $this->getContainer()->get('doctrine')->getManager()





          share|improve this answer












          you can extend ContainerAwareCommand instead and use



          $this->getContainer()->get('doctrine')->getManager()






          share|improve this answer












          share|improve this answer



          share|improve this answer










          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
















          • 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



          Popular posts from this blog

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          政党

          天津地下鉄3号線