Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error When Running php spark schemas with CodeIgniter Shield: Cannot Instantiate Abstract Class #48

Open
aslanutku opened this issue Feb 5, 2024 · 2 comments

Comments

@aslanutku
Copy link

aslanutku commented Feb 5, 2024

Hello,

I've encountered an issue when using the Tatter\Schemas package in combination with the official CodeIgniter Shield package. When attempting to run the php spark schemas command to generate schema files, I receive the following error message:

CodeIgniter v4.4.4 Command Line Tool - Server Time: 2024-02-05 22:02:35 UTC+00:00

[Error]
Cannot instantiate abstract class CodeIgniter\Shield\Models\BaseModel
at VENDORPATH/tatter/schemas/src/Drafter/Handlers/ModelHandler.php:173

Backtrace:
  1    VENDORPATH/tatter/schemas/src/Drafter/Handlers/ModelHandler.php:84
       Tatter\Schemas\Drafter\Handlers\ModelHandler()->getModels()

  2    VENDORPATH/tatter/schemas/src/Schemas.php:165
       Tatter\Schemas\Drafter\Handlers\ModelHandler()->draft()

  3    VENDORPATH/tatter/schemas/src/Commands/Schemas.php:57
       Tatter\Schemas\Schemas()->draft()

  4    SYSTEMPATH/CLI/Commands.php:65
       Tatter\Schemas\Commands\Schemas()->run()

  5    SYSTEMPATH/CLI/Console.php:46
       CodeIgniter\CLI\Commands()->run()

  6    ROOTPATH/spark:102
       CodeIgniter\CLI\Console()->run()

I believe this issue could be related to how the ModelHandler in the Tatter\Schemas package handles model instantiation, particularly with abstract classes like BaseModel in the Shield package.

Any guidance on resolving this error would be greatly appreciated.

Thank you.

@mkuettel
Copy link

A possible workaround might be relocating the abstract classes to a different namespace and adding this namespace to the config variable Schemas::$ignoredNamespaces

@mkuettel
Copy link

I stumbled upon the exact same thing, this is a quickfix #49

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants