-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi-reference.html
More file actions
1052 lines (967 loc) · 68.2 KB
/
api-reference.html
File metadata and controls
1052 lines (967 loc) · 68.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en" class="scroll-smooth">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Forge Kernel - API Reference</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-core.min.js"></script>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/autoloader/prism-autoloader.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
<link rel="stylesheet" href="assets/css/docs.css">
</head>
<body class="bg-gray-50 text-gray-900">
<!-- Navigation -->
<nav class="bg-white shadow-sm border-b">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16">
<div class="flex items-center">
<div class="flex-shrink-0">
<h1 class="text-xl font-bold text-gray-900">
Forge Kernel
</h1>
</div>
<div class="hidden sm:ml-6 sm:flex sm:space-x-8">
<a href="index.html"
class="text-gray-900 inline-flex items-center px-1 pt-1 text-sm font-medium hover:text-blue-600">
Home
</a>
<a href="getting-started.html"
class="text-gray-900 inline-flex items-center px-1 pt-1 text-sm font-medium hover:text-blue-600">
Getting Started
</a>
<a href="core-concepts.html"
class="text-gray-900 inline-flex items-center px-1 pt-1 text-sm font-medium hover:text-blue-600">
Core Concepts
</a>
<a href="modules.html"
class="text-gray-900 inline-flex items-center px-1 pt-1 text-sm font-medium hover:text-blue-600">
Capabilities
</a>
<a href="api-reference.html"
class="text-blue-600 inline-flex items-center px-1 pt-1 text-sm font-medium border-b-2 border-blue-600">
API Reference
</a>
<a href="tutorial.html"
class="text-gray-900 inline-flex items-center px-1 pt-1 text-sm font-medium hover:text-blue-600">
Tutorials
</a>
</div>
</div>
<!-- Mobile menu button -->
<div class="flex items-center sm:hidden">
<button id="mobile-menu-button" class="text-gray-700 hover:text-blue-600 p-2">
<i class="fas fa-bars text-xl"></i>
</button>
</div>
</div>
</div>
<!-- Mobile menu -->
<div id="mobile-menu" class="sm:hidden hidden bg-white border-t border-gray-200">
<div class="px-2 pt-2 pb-3 space-y-1">
<a href="index.html"
class="block px-3 py-2 text-gray-900 hover:text-blue-600">
Home
</a>
<a href="getting-started.html"
class="block px-3 py-2 text-gray-900 hover:text-blue-600">
Getting Started
</a>
<a href="core-concepts.html"
class="block px-3 py-2 text-gray-900 hover:text-blue-600">
Core Concepts
</a>
<a href="modules.html"
class="block px-3 py-2 text-gray-900 hover:text-blue-600">
Capabilities
</a>
<a href="api-reference.html"
class="block px-3 py-2 text-blue-600 font-medium">
API Reference
</a>
<a href="tutorial.html"
class="block px-3 py-2 text-gray-900 hover:text-blue-600">
Tutorial
</a>
</div>
</div>
</nav>
<!-- Main Content -->
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<div class="flex flex-col lg:flex-row gap-8">
<!-- Sidebar Navigation -->
<div id="sidebar-nav" class="lg:w-1/4">
<div class="bg-white rounded-lg shadow-sm p-6 sticky top-8 max-h-[calc(100vh-4rem)] overflow-y-auto">
<h3 class="text-lg font-semibold text-gray-900 mb-4">
API Reference
</h3>
<nav class="space-y-2">
<a href="#overview"
class="nav-link block px-3 py-2 text-sm text-gray-700 rounded-md hover:text-blue-600">
Overview
</a>
<a href="#performance-optimizations"
class="nav-link block px-3 py-2 text-sm text-gray-700 rounded-md hover:text-blue-600">
Performance Optimizations
</a>
<a href="#traits"
class="nav-link block px-3 py-2 text-sm text-gray-700 rounded-md hover:text-blue-600">
Traits
</a>
<a href="#helper-functions"
class="nav-link block px-3 py-2 text-sm text-gray-700 rounded-md hover:text-blue-600">
Helper Functions
</a>
<a href="#helper-classes"
class="nav-link block px-3 py-2 text-sm text-gray-700 rounded-md hover:text-blue-600">
Helper Classes
</a>
<a href="#di-container"
class="nav-link block px-3 py-2 text-sm text-gray-700 rounded-md hover:text-blue-600">
Dependency Injection
</a>
<a href="#contracts"
class="nav-link block px-3 py-2 text-sm text-gray-700 rounded-md hover:text-blue-600">
Contracts & Interfaces
</a>
<a href="#core-services"
class="nav-link block px-3 py-2 text-sm text-gray-700 rounded-md hover:text-blue-600">
Core Services
</a>
<a href="#autoloader"
class="nav-link block px-3 py-2 text-sm text-gray-700 rounded-md hover:text-blue-600">
Autoloader
</a>
<a href="#bootstrap"
class="nav-link block px-3 py-2 text-sm text-gray-700 rounded-md hover:text-blue-600">
Bootstrap Process
</a>
<a href="#cache-system"
class="nav-link block px-3 py-2 text-sm text-gray-700 rounded-md hover:text-blue-600">
Cache System
</a>
</nav>
</div>
</div>
<!-- Main Content -->
<div class="lg:w-3/4">
<div class="bg-white rounded-lg shadow-sm p-8">
<h1 class="text-4xl font-bold text-gray-900 mb-6">
API Reference
</h1>
<p class="text-xl text-gray-600 mb-8">
Comprehensive reference for Forge Kernel internals, APIs, and developer utilities.
</p>
<!-- Overview -->
<section id="overview" class="section-anchor mb-12">
<h2 class="text-2xl font-bold text-gray-900 mb-4">Overview</h2>
<p class="text-gray-600 mb-6">
This API reference provides detailed documentation for Forge Kernel internals, including
performance optimizations, traits, helper functions, services, and architectural components.
This documentation is intended for developers who need to understand or extend the kernel.
</p>
<div class="bg-yellow-50 border-l-4 border-yellow-400 p-4 mb-6">
<p class="text-sm text-yellow-700">
<strong>Note:</strong> Some APIs marked as internal may change between versions. Stable
APIs are clearly indicated.
</p>
</div>
</section>
<!-- Performance Optimizations -->
<section id="performance-optimizations" class="section-anchor mb-12">
<h2 class="text-2xl font-bold text-gray-900 mb-4">Performance Optimizations</h2>
<p class="text-gray-600 mb-6">
Forge Kernel includes several performance optimizations to minimize reflection overhead and
improve runtime performance.
</p>
<h3 class="text-lg font-semibold mb-3">Class Maps</h3>
<p class="text-gray-600 mb-4">
Class maps cache the location of classes to avoid repeated file system scans and reflection
operations. Maps are generated during development and cached in production.
</p>
<h4 class="text-md font-semibold mb-2 mt-4">AppCommandSetup</h4>
<p class="text-gray-600 mb-3">
Caches command class locations to avoid scanning the commands directory on every request.
</p>
<ul class="list-disc list-inside space-y-2 text-gray-600 mb-4">
<li><strong>Cache File:</strong> <code class="bg-gray-100 px-2 py-1 rounded">storage/framework/cache/app_command_class_map.php</code></li>
<li><strong>Scans:</strong> <code class="bg-gray-100 px-2 py-1 rounded">app/Commands</code></li>
<li><strong>Rebuilds:</strong> Automatically on file changes in development</li>
</ul>
<h4 class="text-md font-semibold mb-2 mt-4">ServiceDiscoverSetup</h4>
<p class="text-gray-600 mb-3">
Caches service class locations for automatic service discovery.
</p>
<ul class="list-disc list-inside space-y-2 text-gray-600 mb-4">
<li><strong>Cache File:</strong> <code class="bg-gray-100 px-2 py-1 rounded">storage/framework/cache/class-map.php</code></li>
<li><strong>Scans:</strong> Repositories, Middlewares, Services, Events directories</li>
<li><strong>Production:</strong> Uses cached map, skips scanning</li>
</ul>
<h4 class="text-md font-semibold mb-2 mt-4">MiddlewareLoader</h4>
<p class="text-gray-600 mb-3">
Caches middleware class locations and their registration attributes.
</p>
<ul class="list-disc list-inside space-y-2 text-gray-600 mb-4">
<li><strong>Cache File:</strong> <code class="bg-gray-100 px-2 py-1 rounded">storage/framework/cache/middleware-map.php</code></li>
<li><strong>Scans:</strong> <code class="bg-gray-100 px-2 py-1 rounded">app/Middlewares</code>, <code class="bg-gray-100 px-2 py-1 rounded">engine/Core/Http/Middlewares</code>, module middlewares</li>
</ul>
<h4 class="text-md font-semibold mb-2 mt-4">HelperDiscoverSetup</h4>
<p class="text-gray-600 mb-3">
Caches helper file locations for automatic inclusion.
</p>
<ul class="list-disc list-inside space-y-2 text-gray-600 mb-4">
<li><strong>Cache File:</strong> <code class="bg-gray-100 px-2 py-1 rounded">storage/framework/cache/helper-map.php</code></li>
<li><strong>Scans:</strong> <code class="bg-gray-100 px-2 py-1 rounded">app/helpers</code>, module helper directories</li>
</ul>
<h3 class="text-lg font-semibold mb-3 mt-6">Autoloader Optimizations</h3>
<p class="text-gray-600 mb-4">
The PSR-4 autoloader includes file existence caching to avoid repeated file system checks.
</p>
<ul class="list-disc list-inside space-y-2 text-gray-600 mb-4">
<li><strong>Web (APCu):</strong> Uses APCu for file existence caching with 1-hour TTL</li>
<li><strong>CLI (Memory):</strong> Uses in-memory array cache (max 8,000 entries)</li>
<li><strong>Namespace Mapping:</strong> Maps <code class="bg-gray-100 px-2 py-1 rounded">app</code>, <code class="bg-gray-100 px-2 py-1 rounded">forge</code>, <code class="bg-gray-100 px-2 py-1 rounded">modules</code> namespaces</li>
</ul>
<h3 class="text-lg font-semibold mb-3 mt-6">Cache Proxy Generation</h3>
<p class="text-gray-600 mb-4">
Methods annotated with <code class="bg-gray-100 px-2 py-1 rounded">#[Cache]</code> are wrapped with runtime-generated proxy classes.
</p>
<ul class="list-disc list-inside space-y-2 text-gray-600 mb-4">
<li><strong>Proxy Classes:</strong> Generated once per class, cached in temp directory</li>
<li><strong>Performance:</strong> Avoids reflection on every method call</li>
<li><strong>Reuse:</strong> Proxies are reused across requests</li>
</ul>
<h3 class="text-lg font-semibold mb-3 mt-6">Lazy Module Loading</h3>
<p class="text-gray-600 mb-4">
Modules are loaded on-demand when their classes are first requested, reducing initial bootstrap time.
</p>
<ul class="list-disc list-inside space-y-2 text-gray-600 mb-4">
<li><strong>Trigger:</strong> Container automatically loads modules when <code class="bg-gray-100 px-2 py-1 rounded">App\Modules\*</code> classes are resolved</li>
<li><strong>Benefit:</strong> Only loaded modules consume memory and processing time</li>
</ul>
</section>
<!-- Traits -->
<section id="traits" class="section-anchor mb-12">
<h2 class="text-2xl font-bold text-gray-900 mb-4">Traits</h2>
<p class="text-gray-600 mb-6">
Forge Kernel provides numerous traits organized by category for common functionality.
</p>
<h3 class="text-lg font-semibold mb-3">Core Traits</h3>
<p class="text-gray-600 mb-4">Located in <code class="bg-gray-100 px-2 py-1 rounded">engine/Traits/</code></p>
<div class="overflow-x-auto mb-6">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Trait</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Description</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<tr>
<td class="px-4 py-3 text-sm font-mono">AuthorizeRequests</td>
<td class="px-4 py-3 text-sm text-gray-600">Authorization helpers for request validation</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">CacheLifecycleHooks</td>
<td class="px-4 py-3 text-sm text-gray-600">Cache lifecycle integration hooks</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">ControllerHelper</td>
<td class="px-4 py-3 text-sm text-gray-600">Controller utilities: jsonResponse, view, apiResponse, apiError, csvResponse</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">DataFormatter</td>
<td class="px-4 py-3 text-sm text-gray-600">Debug data formatting utilities</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">DTOHelper</td>
<td class="px-4 py-3 text-sm text-gray-600">Data Transfer Object utilities</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">EnumHelper</td>
<td class="px-4 py-3 text-sm text-gray-600">Enum manipulation utilities</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">FileHelper</td>
<td class="px-4 py-3 text-sm text-gray-600">File operation helpers</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">HasEnvironmentVariables</td>
<td class="px-4 py-3 text-sm text-gray-600">Environment variable access</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">HasMetaData</td>
<td class="px-4 py-3 text-sm text-gray-600">Metadata support for models</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">HasMetadataToJson</td>
<td class="px-4 py-3 text-sm text-gray-600">Metadata JSON serialization</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">HasTimestamps</td>
<td class="px-4 py-3 text-sm text-gray-600">Automatic timestamp management</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">InjectsAssets</td>
<td class="px-4 py-3 text-sm text-gray-600">Asset injection: registerAsset, injectAssets</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">Metadata</td>
<td class="px-4 py-3 text-sm text-gray-600">Metadata operations</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">ModuleHelper</td>
<td class="px-4 py-3 text-sm text-gray-600">Module utilities</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">NamespaceHelper</td>
<td class="px-4 py-3 text-sm text-gray-600">Namespace manipulation</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">PaginationHelper</td>
<td class="px-4 py-3 text-sm text-gray-600">Pagination utilities</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">PathHelper</td>
<td class="px-4 py-3 text-sm text-gray-600">Path manipulation: stripBasePath</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">RepositoryTrait</td>
<td class="px-4 py-3 text-sm text-gray-600">Repository pattern support</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">ResponseHelper</td>
<td class="px-4 py-3 text-sm text-gray-600">Response creation: createErrorResponse, createResponse</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">SecurityHelper</td>
<td class="px-4 py-3 text-sm text-gray-600">Security utilities</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">SoftDeletes</td>
<td class="px-4 py-3 text-sm text-gray-600">Soft delete functionality</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">StringHelper</td>
<td class="px-4 py-3 text-sm text-gray-600">String manipulation utilities</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">TimeTrait</td>
<td class="px-4 py-3 text-sm text-gray-600">Time utilities</td>
</tr>
</tbody>
</table>
</div>
<h3 class="text-lg font-semibold mb-3 mt-6">CLI Traits</h3>
<p class="text-gray-600 mb-4">Located in <code class="bg-gray-100 px-2 py-1 rounded">engine/CLI/Traits/</code></p>
<div class="overflow-x-auto mb-6">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Trait</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Description</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<tr>
<td class="px-4 py-3 text-sm font-mono">CliGenerator</td>
<td class="px-4 py-3 text-sm text-gray-600">CLI generation utilities</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">CommandOptionTrait</td>
<td class="px-4 py-3 text-sm text-gray-600">Command option handling</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">ManagesAssetLinks</td>
<td class="px-4 py-3 text-sm text-gray-600">Asset link management</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">ManagesMaintenanceMode</td>
<td class="px-4 py-3 text-sm text-gray-600">Maintenance mode management</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">OutputHelper</td>
<td class="px-4 py-3 text-sm text-gray-600">CLI output formatting (info, error, success, warning)</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">Wizard</td>
<td class="px-4 py-3 text-sm text-gray-600">Interactive CLI wizards</td>
</tr>
</tbody>
</table>
</div>
<h3 class="text-lg font-semibold mb-3 mt-6">Cache Traits</h3>
<p class="text-gray-600 mb-4">Located in <code class="bg-gray-100 px-2 py-1 rounded">engine/Core/Cache/Traits/</code></p>
<div class="overflow-x-auto mb-6">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Trait</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Description</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<tr>
<td class="px-4 py-3 text-sm font-mono">CacheTrait</td>
<td class="px-4 py-3 text-sm text-gray-600">Cache operations and utilities</td>
</tr>
</tbody>
</table>
</div>
</section>
<!-- Helper Functions -->
<section id="helper-functions" class="section-anchor mb-12">
<h2 class="text-2xl font-bold text-gray-900 mb-4">Helper Functions</h2>
<p class="text-gray-600 mb-6">
Global helper functions available throughout the application. Defined in <code class="bg-gray-100 px-2 py-1 rounded">engine/Core/Support/helpers.php</code>.
</p>
<div class="space-y-6">
<div class="border-l-4 border-blue-500 pl-4">
<h4 class="font-semibold text-gray-900 mb-2">env($key, $default = null)</h4>
<p class="text-gray-600 mb-2">Get environment variable value.</p>
<pre class="bg-gray-100 p-3 rounded"><code class="language-php">$dbHost = env('DB_HOST', 'localhost');
$debug = env('APP_DEBUG', false);</code></pre>
</div>
<div class="border-l-4 border-blue-500 pl-4">
<h4 class="font-semibold text-gray-900 mb-2">cache($key, $value = null, $ttl = null)</h4>
<p class="text-gray-600 mb-2">Cache operations. Get with one argument, set with two or three.</p>
<pre class="bg-gray-100 p-3 rounded"><code class="language-php">// Get
$data = cache('user:123');
// Set
cache('user:123', $userData, 3600);</code></pre>
</div>
<div class="border-l-4 border-blue-500 pl-4">
<h4 class="font-semibold text-gray-900 mb-2">config($key, $default = null)</h4>
<p class="text-gray-600 mb-2">Get configuration value using dot notation.</p>
<pre class="bg-gray-100 p-3 rounded"><code class="language-php">$timezone = config('app.timezone', 'UTC');</code></pre>
</div>
<div class="border-l-4 border-blue-500 pl-4">
<h4 class="font-semibold text-gray-900 mb-2">request_host()</h4>
<p class="text-gray-600 mb-2">Get the current request host (domain + port).</p>
<pre class="bg-gray-100 p-3 rounded"><code class="language-php">$host = request_host(); // Returns: example.com:8080</code></pre>
</div>
<div class="border-l-4 border-blue-500 pl-4">
<h4 class="font-semibold text-gray-900 mb-2">data_get($target, $key, $default = null)</h4>
<p class="text-gray-600 mb-2">Get an item from an array or object using dot notation.</p>
<pre class="bg-gray-100 p-3 rounded"><code class="language-php">$street = data_get($user, 'address.street');
$value = data_get($array, 'nested.key', 'default');</code></pre>
</div>
<div class="border-l-4 border-blue-500 pl-4">
<h4 class="font-semibold text-gray-900 mb-2">e($value)</h4>
<p class="text-gray-600 mb-2">Escape HTML entities in a string.</p>
<pre class="bg-gray-100 p-3 rounded"><code class="language-php">echo e($userInput); // Escapes HTML</code></pre>
</div>
<div class="border-l-4 border-blue-500 pl-4">
<h4 class="font-semibold text-gray-900 mb-2">raw($value)</h4>
<p class="text-gray-600 mb-2">Output a value without escaping.</p>
<pre class="bg-gray-100 p-3 rounded"><code class="language-php">echo raw($htmlContent); // No escaping</code></pre>
</div>
<div class="border-l-4 border-blue-500 pl-4">
<h4 class="font-semibold text-gray-900 mb-2">csrf_token()</h4>
<p class="text-gray-600 mb-2">Get the current CSRF token.</p>
<pre class="bg-gray-100 p-3 rounded"><code class="language-php">$token = csrf_token();</code></pre>
</div>
<div class="border-l-4 border-blue-500 pl-4">
<h4 class="font-semibold text-gray-900 mb-2">csrf_meta()</h4>
<p class="text-gray-600 mb-2">Generate CSRF meta tag for HTML head.</p>
<pre class="bg-gray-100 p-3 rounded"><code class="language-php">echo csrf_meta(); // <meta name="csrf-token" content="..."></code></pre>
</div>
<div class="border-l-4 border-blue-500 pl-4">
<h4 class="font-semibold text-gray-900 mb-2">window_csrf_token()</h4>
<p class="text-gray-600 mb-2">Generate JavaScript to set window.csrfToken.</p>
<pre class="bg-gray-100 p-3 rounded"><code class="language-php">echo window_csrf_token();</code></pre>
</div>
<div class="border-l-4 border-blue-500 pl-4">
<h4 class="font-semibold text-gray-900 mb-2">csrf_input()</h4>
<p class="text-gray-600 mb-2">Generate hidden CSRF input field.</p>
<pre class="bg-gray-100 p-3 rounded"><code class="language-php">echo csrf_input(); // <input type="hidden" name="_token" value="..."></code></pre>
</div>
<div class="border-l-4 border-blue-500 pl-4">
<h4 class="font-semibold text-gray-900 mb-2">tap($value, $callback)</h4>
<p class="text-gray-600 mb-2">Tap utility: execute callback and return value.</p>
<pre class="bg-gray-100 p-3 rounded"><code class="language-php">$result = tap($value, function($v) {
// Do something with $v
});</code></pre>
</div>
<div class="border-l-4 border-blue-500 pl-4">
<h4 class="font-semibold text-gray-900 mb-2">component($name, $type = 'class', $props = [], $fromModule = false)</h4>
<p class="text-gray-600 mb-2">Render a view component.</p>
<pre class="bg-gray-100 p-3 rounded"><code class="language-php">echo component('Button', 'class', ['label' => 'Click']);
echo component('module:Button', 'class', [], true);</code></pre>
</div>
<div class="border-l-4 border-blue-500 pl-4">
<h4 class="font-semibold text-gray-900 mb-2">layout($name, $fromModule = false)</h4>
<p class="text-gray-600 mb-2">Load a layout template.</p>
<pre class="bg-gray-100 p-3 rounded"><code class="language-php">layout('main');
layout('module:layout', true);</code></pre>
</div>
<div class="border-l-4 border-blue-500 pl-4">
<h4 class="font-semibold text-gray-900 mb-2">section($name)</h4>
<p class="text-gray-600 mb-2">Render a section in a layout.</p>
<pre class="bg-gray-100 p-3 rounded"><code class="language-php">echo section('content');</code></pre>
</div>
<div class="border-l-4 border-blue-500 pl-4">
<h4 class="font-semibold text-gray-900 mb-2">form_open($action, $method = 'POST', $attrs = [])</h4>
<p class="text-gray-600 mb-2">Generate form opening tag with CSRF protection.</p>
<pre class="bg-gray-100 p-3 rounded"><code class="language-php">echo form_open('/submit', 'POST', ['class' => 'form']);</code></pre>
</div>
<div class="border-l-4 border-blue-500 pl-4">
<h4 class="font-semibold text-gray-900 mb-2">form_close()</h4>
<p class="text-gray-600 mb-2">Generate form closing tag.</p>
<pre class="bg-gray-100 p-3 rounded"><code class="language-php">echo form_close(); // </form></code></pre>
</div>
<div class="border-l-4 border-blue-500 pl-4">
<h4 class="font-semibold text-gray-900 mb-2">dd(...$vars)</h4>
<p class="text-gray-600 mb-2">Dump variables and exit (debug helper).</p>
<pre class="bg-gray-100 p-3 rounded"><code class="language-php">dd($var1, $var2); // Dumps and exits</code></pre>
</div>
</div>
</section>
<!-- Helper Classes -->
<section id="helper-classes" class="section-anchor mb-12">
<h2 class="text-2xl font-bold text-gray-900 mb-4">Helper Classes</h2>
<p class="text-gray-600 mb-6">
Static helper classes providing common utilities. Located in <code class="bg-gray-100 px-2 py-1 rounded">engine/Core/Helpers/</code>.
</p>
<h3 class="text-lg font-semibold mb-3">Strings</h3>
<p class="text-gray-600 mb-4">String manipulation utilities.</p>
<div class="bg-gray-50 p-4 rounded mb-4">
<ul class="list-disc list-inside space-y-1 text-sm">
<li><code class="bg-gray-100 px-1 rounded">toCamelCase($string)</code> - Convert to camelCase</li>
<li><code class="bg-gray-100 px-1 rounded">toPascalCase($string)</code> - Convert to PascalCase</li>
<li><code class="bg-gray-100 px-1 rounded">toSnakeCase($string)</code> - Convert to snake_case</li>
<li><code class="bg-gray-100 px-1 rounded">toKebabCase($string)</code> - Convert to kebab-case</li>
<li><code class="bg-gray-100 px-1 rounded">toTitleCase($string)</code> - Convert to Title Case</li>
<li><code class="bg-gray-100 px-1 rounded">isCamelCase($string)</code> - Check if camelCase</li>
<li><code class="bg-gray-100 px-1 rounded">isPascalCase($string)</code> - Check if PascalCase</li>
<li><code class="bg-gray-100 px-1 rounded">isSnakeCase($string)</code> - Check if snake_case</li>
<li><code class="bg-gray-100 px-1 rounded">isKebabCase($string)</code> - Check if kebab-case</li>
<li><code class="bg-gray-100 px-1 rounded">truncate($string, $length, $suffix = '...')</code> - Truncate string</li>
<li><code class="bg-gray-100 px-1 rounded">slugify($string, $character = '-')</code> - Create URL slug</li>
<li><code class="bg-gray-100 px-1 rounded">toPlural($string)</code> - Convert to plural form</li>
</ul>
</div>
<h3 class="text-lg font-semibold mb-3 mt-6">Url</h3>
<p class="text-gray-600 mb-4">URL generation utilities.</p>
<div class="bg-gray-50 p-4 rounded mb-4">
<ul class="list-disc list-inside space-y-1 text-sm">
<li><code class="bg-gray-100 px-1 rounded">generateLinks($page, $perPage, $totalPages, $orderBy, $sortBy)</code> - Generate pagination links</li>
<li><code class="bg-gray-100 px-1 rounded">getUrl($path = 'file/uploads')</code> - Get upload URL</li>
<li><code class="bg-gray-100 px-1 rounded">baseUrl($path = '')</code> - Get base URL</li>
</ul>
</div>
<h3 class="text-lg font-semibold mb-3 mt-6">UUID</h3>
<p class="text-gray-600 mb-4">ID generation utilities (UUID, NanoID, ULID).</p>
<div class="bg-gray-50 p-4 rounded mb-4">
<ul class="list-disc list-inside space-y-1 text-sm">
<li><code class="bg-gray-100 px-1 rounded">generate($type = 'uuid', $options = [])</code> - Generate ID</li>
<li>Types: <code class="bg-gray-100 px-1 rounded">'uuid'</code> (v1/v4), <code class="bg-gray-100 px-1 rounded">'nanoid'</code>, <code class="bg-gray-100 px-1 rounded">'ulid'</code></li>
</ul>
<pre class="bg-gray-100 p-3 rounded mt-3"><code class="language-php">UUID::generate('uuid', ['version' => 4]);
UUID::generate('nanoid', ['size' => 21]);
UUID::generate('ulid');</code></pre>
</div>
<h3 class="text-lg font-semibold mb-3 mt-6">Hash</h3>
<p class="text-gray-600 mb-4">Password hashing utilities.</p>
<div class="bg-gray-50 p-4 rounded mb-4">
<ul class="list-disc list-inside space-y-1 text-sm">
<li><code class="bg-gray-100 px-1 rounded">make($password)</code> - Hash password</li>
<li><code class="bg-gray-100 px-1 rounded">check($password, $hash)</code> - Verify password</li>
</ul>
</div>
<h3 class="text-lg font-semibold mb-3 mt-6">Other Helper Classes</h3>
<div class="overflow-x-auto mb-6">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Class</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Description</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<tr>
<td class="px-4 py-3 text-sm font-mono">Debuger</td>
<td class="px-4 py-3 text-sm text-gray-600">Debug utilities: dumpAndExit</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">File</td>
<td class="px-4 py-3 text-sm text-gray-600">File operations</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">FileHelper</td>
<td class="px-4 py-3 text-sm text-gray-600">File helper methods</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">Flash</td>
<td class="px-4 py-3 text-sm text-gray-600">Flash message handling</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">Format</td>
<td class="px-4 py-3 text-sm text-gray-600">Data formatting</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">Framework</td>
<td class="px-4 py-3 text-sm text-gray-600">Framework utilities</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">ModuleResources</td>
<td class="px-4 py-3 text-sm text-gray-600">Module resource management</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">Redirect</td>
<td class="px-4 py-3 text-sm text-gray-600">Redirect utilities</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">TimeConverter</td>
<td class="px-4 py-3 text-sm text-gray-600">Time conversion utilities</td>
</tr>
</tbody>
</table>
</div>
</section>
<!-- DI Container -->
<section id="di-container" class="section-anchor mb-12">
<h2 class="text-2xl font-bold text-gray-900 mb-4">Dependency Injection Container</h2>
<p class="text-gray-600 mb-6">
The <code class="bg-gray-100 px-2 py-1 rounded">Container</code> class provides dependency injection and service management.
Located in <code class="bg-gray-100 px-2 py-1 rounded">engine/Core/DI/Container.php</code>.
</p>
<h3 class="text-lg font-semibold mb-3">Singleton Pattern</h3>
<p class="text-gray-600 mb-4">
The container is a singleton, accessed via <code class="bg-gray-100 px-2 py-1 rounded">Container::getInstance()</code>.
</p>
<pre class="bg-gray-100 p-3 rounded mb-4"><code class="language-php">$container = Container::getInstance();</code></pre>
<h3 class="text-lg font-semibold mb-3 mt-6">Service Registration</h3>
<div class="space-y-4 mb-6">
<div>
<h4 class="font-semibold mb-2">register($class)</h4>
<p class="text-gray-600 mb-2">Register a service class with <code class="bg-gray-100 px-2 py-1 rounded">#[Service]</code> attribute.</p>
<pre class="bg-gray-100 p-3 rounded"><code class="language-php">$container->register(MyService::class);</code></pre>
</div>
<div>
<h4 class="font-semibold mb-2">bind($id, $concrete, $singleton = false)</h4>
<p class="text-gray-600 mb-2">Bind an interface or abstract class to a concrete implementation.</p>
<pre class="bg-gray-100 p-3 rounded"><code class="language-php">$container->bind(LoggerInterface::class, FileLogger::class, true);</code></pre>
</div>
<div>
<h4 class="font-semibold mb-2">singleton($abstract, $concrete)</h4>
<p class="text-gray-600 mb-2">Register a singleton binding.</p>
<pre class="bg-gray-100 p-3 rounded"><code class="language-php">$container->singleton(CacheManager::class, CacheManager::class);</code></pre>
</div>
</div>
<h3 class="text-lg font-semibold mb-3 mt-6">Service Resolution</h3>
<div class="space-y-4 mb-6">
<div>
<h4 class="font-semibold mb-2">make($abstract)</h4>
<p class="text-gray-600 mb-2">Resolve a service instance. Uses reflection for constructor injection.</p>
<pre class="bg-gray-100 p-3 rounded"><code class="language-php">$service = $container->make(MyService::class);</code></pre>
</div>
<div>
<h4 class="font-semibold mb-2">get($id)</h4>
<p class="text-gray-600 mb-2">Get a service by ID (alias for make).</p>
<pre class="bg-gray-100 p-3 rounded"><code class="language-php">$service = $container->get(MyService::class);</code></pre>
</div>
</div>
<h3 class="text-lg font-semibold mb-3 mt-6">Service Tags</h3>
<p class="text-gray-600 mb-4">
Tag services for grouped retrieval.
</p>
<pre class="bg-gray-100 p-3 rounded mb-4"><code class="language-php">$container->tag('middleware', [
AuthMiddleware::class,
CsrfMiddleware::class,
]);
$middlewares = $container->tagged('middleware');</code></pre>
<h3 class="text-lg font-semibold mb-3 mt-6">Instance Management</h3>
<p class="text-gray-600 mb-4">
Manually set or override service instances.
</p>
<pre class="bg-gray-100 p-3 rounded mb-4"><code class="language-php">$container->setInstance(MyService::class, $customInstance);</code></pre>
<h3 class="text-lg font-semibold mb-3 mt-6">Automatic Module Loading</h3>
<p class="text-gray-600 mb-4">
When resolving <code class="bg-gray-100 px-2 py-1 rounded">App\Modules\*</code> classes, the container automatically loads the corresponding module if not already loaded.
</p>
<pre class="bg-gray-100 p-3 rounded mb-4"><code class="language-php">// Module is automatically loaded when this class is resolved
$service = $container->make(\App\Modules\ForgeAuth\Services\AuthService::class);</code></pre>
<h3 class="text-lg font-semibold mb-3 mt-6">Cache Proxy Wrapping</h3>
<p class="text-gray-600 mb-4">
Services with methods annotated with <code class="bg-gray-100 px-2 py-1 rounded">#[Cache]</code> are automatically wrapped with cache proxy classes for performance.
</p>
</section>
<!-- Contracts -->
<section id="contracts" class="section-anchor mb-12">
<h2 class="text-2xl font-bold text-gray-900 mb-4">Contracts & Interfaces</h2>
<p class="text-gray-600 mb-6">
Interfaces and contracts available in the kernel. Located in <code class="bg-gray-100 px-2 py-1 rounded">engine/Core/Contracts/</code>.
</p>
<div class="overflow-x-auto mb-6">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Interface</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Description</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<tr>
<td class="px-4 py-3 text-sm font-mono">DatabaseConfigInterface</td>
<td class="px-4 py-3 text-sm text-gray-600">Database configuration contract</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">DatabaseConnectionInterface</td>
<td class="px-4 py-3 text-sm text-gray-600">Database connection contract (exec, query, prepare, transactions)</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">QueryBuilderInterface</td>
<td class="px-4 py-3 text-sm text-gray-600">Query builder contract (select, where, orderBy, etc.)</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">DebugBarInterface</td>
<td class="px-4 py-3 text-sm text-gray-600">Debug bar integration contract</td>
</tr>
</tbody>
</table>
</div>
</section>
<!-- Core Services -->
<section id="core-services" class="section-anchor mb-12">
<h2 class="text-2xl font-bold text-gray-900 mb-4">Core Services</h2>
<p class="text-gray-600 mb-6">
Core services available in the kernel. Located in <code class="bg-gray-100 px-2 py-1 rounded">engine/Core/Services/</code>.
</p>
<div class="overflow-x-auto mb-6">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Service</th>
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 uppercase">Description</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<tr>
<td class="px-4 py-3 text-sm font-mono">ArchiveService</td>
<td class="px-4 py-3 text-sm text-gray-600">Archive operations (zip, tar, etc.)</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">CacheRefreshListener</td>
<td class="px-4 py-3 text-sm text-gray-600">Cache refresh event handling</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">DatabaseManager</td>
<td class="px-4 py-3 text-sm text-gray-600">Database connection and management</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">GitService</td>
<td class="px-4 py-3 text-sm text-gray-600">Git repository operations</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">InteractiveSelect</td>
<td class="px-4 py-3 text-sm text-gray-600">Interactive CLI selection menus</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">ManifestService</td>
<td class="px-4 py-3 text-sm text-gray-600">Module manifest management</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">ModuleAssetManager</td>
<td class="px-4 py-3 text-sm text-gray-600">Module asset linking and management</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">RegistryService</td>
<td class="px-4 py-3 text-sm text-gray-600">Module registry operations</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">TemplateGenerator</td>
<td class="px-4 py-3 text-sm text-gray-600">Code template generation</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">TokenManager</td>
<td class="px-4 py-3 text-sm text-gray-600">CSRF token generation and management</td>
</tr>
<tr>
<td class="px-4 py-3 text-sm font-mono">VersionService</td>
<td class="px-4 py-3 text-sm text-gray-600">Version management and comparison</td>
</tr>
</tbody>
</table>
</div>
</section>
<!-- Autoloader -->
<section id="autoloader" class="section-anchor mb-12">
<h2 class="text-2xl font-bold text-gray-900 mb-4">Autoloader</h2>
<p class="text-gray-600 mb-6">
The <code class="bg-gray-100 px-2 py-1 rounded">Autoloader</code> class implements PSR-4 autoloading with performance optimizations.
Located in <code class="bg-gray-100 px-2 py-1 rounded">engine/Core/Autoloader.php</code>.
</p>
<h3 class="text-lg font-semibold mb-3">PSR-4 Autoloading</h3>
<p class="text-gray-600 mb-4">
Implements the PSR-4 autoloading standard for automatic class loading.
</p>
<h3 class="text-lg font-semibold mb-3 mt-6">Namespace Mapping</h3>
<p class="text-gray-600 mb-4">
Maps namespaces to base directories:
</p>
<ul class="list-disc list-inside space-y-2 text-gray-600 mb-4">
<li><code class="bg-gray-100 px-2 py-1 rounded">app</code> → <code class="bg-gray-100 px-2 py-1 rounded">BASE_PATH/app</code></li>
<li><code class="bg-gray-100 px-2 py-1 rounded">forge</code> → <code class="bg-gray-100 px-2 py-1 rounded">BASE_PATH/engine</code></li>
<li><code class="bg-gray-100 px-2 py-1 rounded">modules</code> → <code class="bg-gray-100 px-2 py-1 rounded">BASE_PATH/modules</code></li>
</ul>
<h3 class="text-lg font-semibold mb-3 mt-6">File Existence Caching</h3>
<p class="text-gray-600 mb-4">
Caches file existence checks to avoid repeated file system operations:
</p>
<ul class="list-disc list-inside space-y-2 text-gray-600 mb-4">
<li><strong>Web (APCu):</strong> Uses APCu for file existence caching with 1-hour TTL</li>
<li><strong>CLI (Memory):</strong> Uses in-memory array cache with maximum 8,000 entries</li>
<li><strong>Performance:</strong> Significantly reduces file system I/O</li>
</ul>
<h3 class="text-lg font-semibold mb-3 mt-6">Path Registration</h3>
<p class="text-gray-600 mb-4">
Register additional namespace paths programmatically.
</p>
<pre class="bg-gray-100 p-3 rounded mb-4"><code class="language-php">Autoloader::addPath('MyNamespace', '/path/to/classes');</code></pre>
</section>
<!-- Bootstrap -->
<section id="bootstrap" class="section-anchor mb-12">
<h2 class="text-2xl font-bold text-gray-900 mb-4">Bootstrap Process</h2>
<p class="text-gray-600 mb-6">
The bootstrap process initializes the kernel. Setup classes are located in <code class="bg-gray-100 px-2 py-1 rounded">engine/Core/Bootstrap/</code>.
</p>
<h3 class="text-lg font-semibold mb-3">Bootstrap</h3>
<p class="text-gray-600 mb-4">
Main bootstrap orchestrator that coordinates all setup classes.
</p>
<h3 class="text-lg font-semibold mb-3 mt-6">Setup Classes</h3>
<div class="space-y-4 mb-6">
<div>
<h4 class="font-semibold mb-2">AppCommandSetup</h4>
<p class="text-gray-600 mb-2">Discovers and registers application commands. Builds command class map cache.</p>
</div>
<div>
<h4 class="font-semibold mb-2">ContainerCLISetup</h4>
<p class="text-gray-600 mb-2">Initializes the dependency injection container for CLI context.</p>
</div>
<div>
<h4 class="font-semibold mb-2">ContainerWebSetup</h4>
<p class="text-gray-600 mb-2">Initializes the dependency injection container for web context.</p>
</div>
<div>
<h4 class="font-semibold mb-2">HelperDiscoverSetup</h4>
<p class="text-gray-600 mb-2">Discovers and includes helper files. Builds helper map cache.</p>
</div>
<div>
<h4 class="font-semibold mb-2">ModuleSetup</h4>
<p class="text-gray-600 mb-2">Loads and initializes modules from the modules directory.</p>
</div>
<div>
<h4 class="font-semibold mb-2">RouterSetup</h4>
<p class="text-gray-600 mb-2">Initializes the routing system and loads route definitions.</p>
</div>
<div>
<h4 class="font-semibold mb-2">ServiceDiscoverSetup</h4>
<p class="text-gray-600 mb-2">Discovers services with <code class="bg-gray-100 px-2 py-1 rounded">#[Service]</code> attribute and registers them. Builds service class map cache.</p>
</div>
</div>
</section>
<!-- Cache System -->
<section id="cache-system" class="section-anchor mb-12">
<h2 class="text-2xl font-bold text-gray-900 mb-4">Cache System</h2>
<p class="text-gray-600 mb-6">
The cache system provides method-level caching with automatic proxy generation.
</p>
<h3 class="text-lg font-semibold mb-3">Cache Drivers</h3>
<p class="text-gray-600 mb-4">
Multiple cache drivers are available:
</p>
<ul class="list-disc list-inside space-y-2 text-gray-600 mb-4">
<li><strong>File:</strong> File-based caching (default)</li>
<li><strong>Memory:</strong> In-memory caching for single request</li>
<li><strong>SQLite:</strong> SQLite database caching</li>
</ul>
<h3 class="text-lg font-semibold mb-3 mt-6">Cache Manager</h3>
<p class="text-gray-600 mb-4">
The <code class="bg-gray-100 px-2 py-1 rounded">CacheManager</code> provides cache operations with tag support.
</p>
<pre class="bg-gray-100 p-3 rounded mb-4"><code class="language-php">$cache = Container::getInstance()->make(CacheManager::class);
$cache->set('key', $value, 3600);
$value = $cache->get('key');
// Tagged cache
$cache->tags(['users', 'profile'])->set('user:123', $user);
$cache->clearTag('users');</code></pre>
<h3 class="text-lg font-semibold mb-3 mt-6">Cache Attributes</h3>
<p class="text-gray-600 mb-4">
Methods can be annotated with <code class="bg-gray-100 px-2 py-1 rounded">#[Cache]</code> for automatic caching.
</p>
<pre class="bg-gray-100 p-3 rounded mb-4"><code class="language-php">use Forge\Core\Cache\Attributes\Cache;
class UserService
{
#[Cache(ttl: 3600)]
public function getUser(int $id): User
{
// Expensive operation
return $this->repository->find($id);
}
}</code></pre>
<h3 class="text-lg font-semibold mb-3 mt-6">Cache Interceptor</h3>
<p class="text-gray-600 mb-4">
The <code class="bg-gray-100 px-2 py-1 rounded">CacheInterceptor</code> intercepts method calls and handles cache lookup/storage.
</p>
<h3 class="text-lg font-semibold mb-3 mt-6">Proxy Generation</h3>
<p class="text-gray-600 mb-4">
The <code class="bg-gray-100 px-2 py-1 rounded">ProxyGenerator</code> creates runtime proxy classes for services with cached methods.
</p>
<ul class="list-disc list-inside space-y-2 text-gray-600 mb-4">
<li>Proxies are generated once per class and cached in the temp directory</li>
<li>Proxies extend the original class and implement <code class="bg-gray-100 px-2 py-1 rounded">ProxyMarkerInterface</code></li>
<li>Method calls are intercepted and routed through the cache interceptor</li>
<li>Avoids reflection overhead on every method call</li>
</ul>
</section>
</div>
</div>
</div>