I am trying to automate a task. Which is sending emails automatically every week to some people. I created a MailController, inside it implemented a function which sends the emails. What i want to do now is to make my app call the function automatically every week or month.
What i tried is to implement a new command which would execute my function and then make a script to repeat that command.
<?php
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class MailCommand extends Command {
protected function configure () {
$defaultName = 'app:mailAuto';
$this->setDescription("Permet d'envoyer des mails automatiquement lorsque le parc n'est pas à jour");
$this->setHelp("Je serai affiche si on lance la commande bin/console app:mailAuto -h");
}
public function execute (InputInterface $input, OutputInterface $output) {
// $controller = new MailController();
// $controller->warningMailAction();
$output->writeln('coucou !');
}
}
When executing the command i created i get this messages:
In FileLoader.php line 166:
The autoloader expected class "App\Command\commandeMailAuto" to be defined
in file "/var/www/html/ParcAuto/vendor/composer/../../src/Command/commandeM
ailAuto.php". The file was found but the class was not in it, the class nam
e or namespace probably has a typo in /var/www/html/ParcAuto/config/service
s.yaml (which is loaded in resource "/var/www/html/ParcAuto/config/services
.yaml").
In DebugClassLoader.php line 213:
The autoloader expected class "App\Command\commandeMailAuto" to be defined
in file "/var/www/html/ParcAuto/vendor/composer/../../src/Command/commandeM
ailAuto.php". The file was found but the class was not in it, the class nam
e or namespace probably has a typo.
I'm running symfony 4.3.2, the controller i'm trying to call extends AbstractController, my services.yaml is the default one. I think i missed some configurations but i can't find out which exactly. Thank you for your help, tell me if you need more information.