Skip to content

Feature/add or use caching when available#15

Draft
roy-bongers wants to merge 2 commits intomasterfrom
feature/add-or-use-caching-when-available
Draft

Feature/add or use caching when available#15
roy-bongers wants to merge 2 commits intomasterfrom
feature/add-or-use-caching-when-available

Conversation

@roy-bongers
Copy link
Copy Markdown
Member

New files:

  • src/Support/ModuleManifest.php — reads/writes the manifest at bootstrap/cache/modules.php. Single file_exists + require on first access, then pure array lookups.
  • src/Console/ModuleCacheCommand.php — php artisan module:cache scans all registered modules and writes the manifest
  • src/Console/ModuleClearCommand.php — php artisan module:clear deletes the manifest

Modified files:

  • src/ModulesServiceProvider.php — registers ModuleManifest as singleton + the two commands
  • src/Module.php — every loader method (loadMigrations, loadViews, loadTranslations, loadConfigs, registerFactories, registerRoutes) now checks the manifest first. If cached, uses the pre-scanned paths (zero file_exists/glob calls). Falls
    back to the original behavior when no manifest exists.

Performance impact with 200 modules:

  • Without manifest: ~1200 stat calls + ~400 glob calls per request
  • With manifest: 1 file_exists + 1 require total (the manifest file), then pure in-memory array lookups

Usage:
php artisan module:cache # generate after deploy
php artisan module:clear # clear during development

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

Successfully merging this pull request may close these issues.

1 participant