CLI application

  • I need to run a cron job in my server to run a specific script which import data from an API and save in local database.


    In symfony I normally create a command and in the server I create a cron job to run that command every X hours.


    to do the same I have create my package and with all details (Model/Service/Commands etc), and regist the console command under the console.init in events.


    when the service to save the data on the database from the controller works without any problem.


    When I call the command throw me the follow error:

    Code
    1. [Symfony\Component\Debug\Exception\FatalThrowableError]
    2. Call to a member function load() on null


    this happen when I execute the line to create the Model

  • SPQRInc

    Approved the thread.
  • Hi SPQRInc. Thanks for your help.

    I give a look and implement that solution but unfortunately that doesn't work.


    What I have done instead use the model I have use the ORM Query Builder, and instead call the object I call the App::db()->insert('@tbale', $data).


    That solve my problem.


    Thanks for your help