running on 3.0.5-pl and using Formit 5.1.0-pl.
I have written a schema and parsed it using MIGX, created the tables and now trying to use that package as a hook.
I’m receiving this error: Path specified for package Savesampletodb is not a valid or accessible directory: mysite/core/components/savesampletodb/model/
There is no “model” folder inside my package being created when parsing my schema using MIGX. Isn’t that the “old” (2.X) folder structure and the “new” (3.X) folder structure is “src/Model” ?
How exactly do you try to use your custom class in the hook snippet?
The problem could be that you use $modx->addPackage() and specify the path with '/model/' in the second function parameter yourself.
Generally with MIGX in MODX 3, you don’t have to call $modx->addPackage() yourself. The custom package should already get added in the file core/components/savesampletodb/bootstrap.php when MODX is initialized.
In a custom snippet you can then just use your custom class by using the full class name (including the namespace) → Something like
$modx->getCollection('YourPackageName\\Model\\YourClassName');
// or
use YourPackageName\Model\YourClassName;
$modx->getCollection(YourClassName::class);
This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.