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:
this happen when I execute the line to create the Model
Code
- $data = [...]
- // Model name is instagram which will contain the data from the instagram account of the user
- $save = Instagram::create($data);
- $save->save();
- if I call the same service from the controller all data go to the database without any problems or messages.
- same happen when I read the data, but with a different message. If I run the follow code
- $data = Instagram::findAll();
- read all data on the database but when I call in the command throw the follow error:
- [Symfony\Component\Debug\Exception\FatalThrowableError]
- Call to a member function getMetadata() on null
- Thanks for the help and let me know if you need more details