Hi all,
I have an issue that I am not sure how to solve. I have created a cli.php and a task that will use existing models to perform operations (import in this case). The model calls a library I made on the "afterUpdate" event. This works fine if for example I use the GUI to edit a record and save it again. However, I want to do the same thing (edit specific records) using the cli task I did. Here, although the model works fine, the library fails with the following error:
Fatal error: Uncaught Error: Class 'Importer' not found in <path here...>/app/cli.php:68
In my cli.php I am using this:
$loader->registerNamespaces([
'WebErp\Models' => __DIR__ . '/models',
'WebErpCLI\Models' => __DIR__ . '/climodels',
'WebErpCLI\Tasks' => __DIR__ . '/tasks',
]);
$loader->registerDirs([
__DIR__ . "/tasks",
__DIR__ . "/models",
__DIR__ . "/climodels",
]);
But when I try to add the folder and namespace of the Libary (located under /app/library/Importer/Importer.php
) I end up with similar errors, even when I add a shared DI component like so:
$di->set('importer', function () {
return new Importer();
});
I am pretty sure I am doing somthing wrong, but I can't figure out what it is....