diff --git a/README.md b/README.md index cec6a19..038bb02 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,11 @@ All modules can communicate with the other modules using their API endpoints. * **html_admin** - A folder holding front-end templates (`*.html.twig files`) for the administrator panel. * **html_client** - A folder holding front-end templates (`*.html.twig files`) for the client / guest area. +### Commands CLI folder (Optional) + +* **ClassConsole.php** - A file where you can run CLI console by ```php console.php your:cli``` +* Multiple files can be added to the folder as long as they have different names and do not conflict with existing ones. + ### Controller folder * **Admin.php** - Defines the module's routes and navigation items for the administrator panel. diff --git a/src/Commands/ExampleDI.php b/src/Commands/ExampleDI.php new file mode 100644 index 0000000..cbd93ea --- /dev/null +++ b/src/Commands/ExampleDI.php @@ -0,0 +1,69 @@ +di = $di; + } + + /** + * @return Container|null + */ + public function getDi(): ?Container + { + return $this->di; + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return int + */ + protected function execute(InputInterface $input, OutputInterface $output): int + { + $service = $this->di['mod_service']('system'); + try { + $service->clearCache(); + } catch (\Exception $e) { + $output->writeln('An error occurred: ' . $e->getMessage() . ''); + return Command::FAILURE; + } finally { + $output->writeln('Successfully cleared the cache.'); + return Command::SUCCESS; + } + } +} diff --git a/src/Commands/ExampleError.php b/src/Commands/ExampleError.php new file mode 100644 index 0000000..2ed7122 --- /dev/null +++ b/src/Commands/ExampleError.php @@ -0,0 +1,61 @@ +di = $di; + } + + /** + * @return Container|null + */ + public function getDi(): ?Container + { + return $this->di; + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + try { + $output->writeln('This is your example error console'); + } catch (\Exception $e) { + $output->writeln('This is your example error console triggered by an exception'); + return Command::FAILURE; + } + return Command::SUCCESS; + } +} \ No newline at end of file diff --git a/src/Commands/ExampleInfo.php b/src/Commands/ExampleInfo.php new file mode 100644 index 0000000..6715749 --- /dev/null +++ b/src/Commands/ExampleInfo.php @@ -0,0 +1,56 @@ +di = $di; + } + + /** + * @return Container|null + */ + public function getDi(): ?Container + { + return $this->di; + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $output->writeln('This is your example info.'); + return Command::SUCCESS; + } +} \ No newline at end of file