You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Services with the <codeclass="bg-gray-100 px-2 py-1 rounded">#[Service]</code> attribute are automatically discovered from specific directories:
201
+
Services are automatically discovered from <strong>any folder</strong> in your application or modules when they have the <codeclass="bg-gray-100 px-2 py-1 rounded">#[Service]</code> or <codeclass="bg-gray-100 px-2 py-1 rounded">#[Discoverable]</code> attribute. The framework recursively scans all directories, so you can organize your code however you prefer.
<li><codeclass="bg-gray-100 px-2 py-1 rounded">#[Service]</code> - Register a class as a service in the dependency injection container</li>
208
+
<li><codeclass="bg-gray-100 px-2 py-1 rounded">#[Discoverable]</code> - Semantically marks a class as discoverable (same behavior as <codeclass="bg-gray-100 px-2 py-1 rounded">#[Service]</code>, useful for non-service classes that need DI)</li>
209
+
</ul>
210
+
<pclass="text-gray-600 mb-4">
211
+
<strong>Discovery Scope:</strong> Services are discovered from:
<li>Same structure in modules: <codeclass="bg-gray-100 px-2 py-1 rounded">modules/ModuleName/src/Services/</code>, etc.</li>
214
+
<li>All directories under <codeclass="bg-gray-100 px-2 py-1 rounded">app/</code></li>
215
+
<li>All directories under <codeclass="bg-gray-100 px-2 py-1 rounded">modules/*/src/</code></li>
216
+
<li>Engine core directories</li>
209
217
</ul>
210
218
<pclass="text-gray-600 mb-4">
211
-
Service discovery happens once at bootstrap and uses a class map cache for performance. If you add a new service and it's not being discovered, clear the cache with <codeclass="bg-gray-100 px-2 py-1 rounded">php forge.php cache:flush</code>.
219
+
Service discovery happens once at bootstrap and uses an incremental class map cache for performance. The cache automatically updates when files change. If you add a new service and it's not being discovered, clear the cache with <codeclass="bg-gray-100 px-2 py-1 rounded">php forge.php cache:flush</code>.
Migrations can be organized by scope: app, engine, or module. This allows you to run migrations selectively.
675
+
Migrations can be organized by scope: app, engine, or module. The framework supports both <strong>folder-based</strong> and <strong>attribute-based</strong> migration discovery.
<li><strong>Folder-based:</strong> Migrations in traditional <codeclass="bg-gray-100 px-2 py-1 rounded">Database/Migrations/</code> directories</li>
684
+
<li><strong>Attribute-based:</strong> Any migration class with <codeclass="bg-gray-100 px-2 py-1 rounded">#[Migration]</code> attribute, regardless of folder location</li>
685
+
</ul>
686
+
<pclass="text-gray-600 mb-4">
687
+
Both methods work together - migrations discovered through either method are included when running migrations.
Application-specific migrations in <codeclass="bg-gray-100 px-2 py-1 rounded">app/Database/migrations/</code>:
692
+
Application-specific migrations can be placed in <codeclass="bg-gray-100 px-2 py-1 rounded">app/Database/migrations/</code> or anywhere in <codeclass="bg-gray-100 px-2 py-1 rounded">app/</code> with the <codeclass="bg-gray-100 px-2 py-1 rounded">#[Migration]</code> attribute:
Module-specific migrations in <codeclass="bg-gray-100 px-2 py-1 rounded">modules/{ModuleName}/src/Database/Migrations/</code>:
708
+
Module-specific migrations can be placed in <codeclass="bg-gray-100 px-2 py-1 rounded">modules/{ModuleName}/src/Database/Migrations/</code> or anywhere in <codeclass="bg-gray-100 px-2 py-1 rounded">modules/{ModuleName}/src/</code> with the <codeclass="bg-gray-100 px-2 py-1 rounded">#[Migration]</code> attribute:
Forge uses attributes for dependency injection. Services are automatically discovered from specific directories when they have the <codeclass="bg-gray-100 px-2 py-1 rounded">#[Service]</code> attribute.
319
+
Forge uses attributes for dependency injection. Services are automatically discovered from <strong>any folder</strong> in your application or modules when they have the <codeclass="bg-gray-100 px-2 py-1 rounded">#[Service]</code> or <codeclass="bg-gray-100 px-2 py-1 rounded">#[Discoverable]</code> attribute.
Services are automatically discovered at bootstrap from these directories:
324
+
The framework automatically scans all directories recursively, so you can organize your code however you prefer. No specific folder structure is required.
<li><codeclass="bg-gray-100 px-2 py-1 rounded">#[Service]</code> - Register a class as a service in the dependency injection container</li>
332
+
<li><codeclass="bg-gray-100 px-2 py-1 rounded">#[Discoverable]</code> - Semantically marks a class as discoverable (same behavior as <codeclass="bg-gray-100 px-2 py-1 rounded">#[Service]</code>)</li>
333
+
</ul>
334
+
335
+
<pclass="text-gray-600 mb-4">
336
+
<strong>Discovery Scope:</strong> Services are discovered from all directories under:
<li>Same structure in modules: <codeclass="bg-gray-100 px-2 py-1 rounded">modules/ModuleName/src/Services/</code>, etc.</li>
339
+
<li><codeclass="bg-gray-100 px-2 py-1 rounded">app/</code> - Any folder structure</li>
340
+
<li><codeclass="bg-gray-100 px-2 py-1 rounded">modules/*/src/</code> - Any folder structure within module source directories</li>
333
341
</ul>
334
342
335
343
<pclass="text-gray-600 mb-4">
336
-
<strong>Important:</strong>Services must be placed in these proper directories and have the <codeclass="bg-gray-100 px-2 py-1 rounded">#[Service]</code>attribute to be automatically discovered. This applies to both app and module (capability) services.
344
+
<strong>Note:</strong>While you can use any folder structure, traditional structures like <codeclass="bg-gray-100 px-2 py-1 rounded">app/Services/</code>or <codeclass="bg-gray-100 px-2 py-1 rounded">app/Repositories/</code> still work perfectly. The framework discovers services based on attributes, not folder location.
0 commit comments