-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
835 lines (712 loc) Β· 25.7 KB
/
index.html
File metadata and controls
835 lines (712 loc) Β· 25.7 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>BareMetalPHP - Lightning-Fast PHP with Go</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:root {
--primary: #06b6d4;
--primary-dark: #0891b2;
--accent: #f97316;
--bg-dark: #0a0e1a;
--bg-darker: #050810;
--bg-card: #111827;
--text-primary: #f9fafb;
--text-secondary: #9ca3af;
--border: #1f2937;
--code-bg: #1e293b;
--sidebar-width: 280px;
}
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
background: var(--bg-dark);
color: var(--text-primary);
line-height: 1.7;
overflow-x: hidden;
}
/* Hero Background Effect */
.hero-bg {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 600px;
background: radial-gradient(ellipse at top, rgba(6, 182, 212, 0.15), transparent 70%),
radial-gradient(ellipse at bottom right, rgba(249, 115, 22, 0.1), transparent 60%);
pointer-events: none;
z-index: 0;
}
.container {
display: flex;
max-width: 1400px;
margin: 0 auto;
position: relative;
z-index: 1;
}
/* Sidebar */
.sidebar {
width: var(--sidebar-width);
position: fixed;
height: 100vh;
overflow-y: auto;
padding: 2rem 1.5rem;
background: rgba(17, 24, 39, 0.8);
backdrop-filter: blur(10px);
border-right: 1px solid var(--border);
}
.sidebar::-webkit-scrollbar {
width: 6px;
}
.sidebar::-webkit-scrollbar-track {
background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
background: var(--border);
border-radius: 3px;
}
.logo {
display: flex;
align-items: center;
gap: 0.75rem;
margin-bottom: 2.5rem;
font-size: 1.25rem;
font-weight: 700;
color: var(--text-primary);
}
.logo-icon {
width: 32px;
height: 32px;
background: linear-gradient(135deg, var(--primary), var(--accent));
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
font-size: 1.2rem;
}
.nav-section {
margin-bottom: 1.5rem;
}
.nav-section-title {
font-size: 0.75rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.05em;
color: var(--text-secondary);
margin-bottom: 0.5rem;
padding: 0 0.75rem;
}
.nav-link {
display: block;
padding: 0.5rem 0.75rem;
color: var(--text-secondary);
text-decoration: none;
border-radius: 6px;
transition: all 0.2s;
font-size: 0.9rem;
}
.nav-link:hover {
color: var(--text-primary);
background: rgba(6, 182, 212, 0.1);
}
.nav-link.active {
color: var(--primary);
background: rgba(6, 182, 212, 0.15);
font-weight: 500;
}
/* Main Content */
.main-content {
margin-left: var(--sidebar-width);
flex: 1;
padding: 3rem 4rem;
max-width: 900px;
}
/* Hero Section */
.hero {
padding: 4rem 0 6rem;
}
.hero h1 {
font-size: 3.5rem;
font-weight: 800;
line-height: 1.1;
margin-bottom: 1.5rem;
background: linear-gradient(135deg, var(--primary), var(--accent));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.hero-subtitle {
font-size: 1.35rem;
color: var(--text-secondary);
margin-bottom: 2rem;
line-height: 1.6;
}
.cta-buttons {
display: flex;
gap: 1rem;
margin-top: 2rem;
}
.btn {
padding: 0.75rem 1.75rem;
border-radius: 8px;
font-weight: 600;
text-decoration: none;
transition: all 0.2s;
display: inline-block;
font-size: 0.95rem;
}
.btn-primary {
background: var(--primary);
color: white;
}
.btn-primary:hover {
background: var(--primary-dark);
transform: translateY(-2px);
box-shadow: 0 10px 25px rgba(6, 182, 212, 0.3);
}
.btn-secondary {
background: var(--bg-card);
color: var(--text-primary);
border: 1px solid var(--border);
}
.btn-secondary:hover {
border-color: var(--primary);
background: rgba(6, 182, 212, 0.1);
}
/* Feature Cards */
.feature-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 1.5rem;
margin: 3rem 0;
}
.feature-card {
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: 12px;
padding: 1.75rem;
transition: all 0.3s;
}
.feature-card:hover {
border-color: var(--primary);
transform: translateY(-4px);
box-shadow: 0 10px 30px rgba(6, 182, 212, 0.2);
}
.feature-icon {
font-size: 2rem;
margin-bottom: 1rem;
}
.feature-card h3 {
font-size: 1.15rem;
margin-bottom: 0.75rem;
color: var(--text-primary);
}
.feature-card p {
color: var(--text-secondary);
font-size: 0.9rem;
line-height: 1.6;
}
/* Sections */
section {
margin: 5rem 0;
scroll-margin-top: 2rem;
}
h2 {
font-size: 2rem;
font-weight: 700;
margin-bottom: 1.5rem;
color: var(--text-primary);
display: flex;
align-items: center;
gap: 0.75rem;
}
h3 {
font-size: 1.4rem;
font-weight: 600;
margin: 2.5rem 0 1rem;
color: var(--text-primary);
}
p {
color: var(--text-secondary);
margin-bottom: 1.25rem;
font-size: 1rem;
}
ul {
list-style: none;
margin: 1.5rem 0;
}
ul li {
padding: 0.5rem 0 0.5rem 1.75rem;
color: var(--text-secondary);
position: relative;
}
ul li:before {
content: "β";
position: absolute;
left: 0;
color: var(--primary);
font-weight: bold;
}
/* Code Blocks */
pre {
background: var(--code-bg);
border: 1px solid var(--border);
border-radius: 10px;
padding: 1.5rem;
overflow-x: auto;
margin: 1.5rem 0;
font-size: 0.9rem;
line-height: 1.6;
}
code {
color: #e2e8f0;
font-family: 'Fira Code', 'Courier New', monospace;
}
.inline-code {
background: var(--code-bg);
padding: 0.2rem 0.5rem;
border-radius: 4px;
font-size: 0.9em;
color: var(--primary);
font-family: 'Fira Code', monospace;
}
/* Architecture Diagram */
.arch-diagram {
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: 12px;
padding: 2rem;
margin: 2rem 0;
overflow-x: auto;
}
.arch-diagram pre {
background: transparent;
border: none;
padding: 0;
margin: 0;
font-size: 0.85rem;
}
/* Alert Box */
.alert {
background: rgba(6, 182, 212, 0.1);
border-left: 4px solid var(--primary);
padding: 1.25rem;
border-radius: 8px;
margin: 2rem 0;
}
.alert strong {
color: var(--primary);
display: block;
margin-bottom: 0.5rem;
}
/* Responsive */
@media (max-width: 1024px) {
.sidebar {
transform: translateX(-100%);
transition: transform 0.3s;
}
.sidebar.open {
transform: translateX(0);
}
.main-content {
margin-left: 0;
padding: 2rem 1.5rem;
}
.hero h1 {
font-size: 2.5rem;
}
.feature-grid {
grid-template-columns: 1fr;
}
}
/* Smooth scroll */
html {
scroll-behavior: smooth;
}
</style>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/tokyo-night-dark.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
</head>
<body>
<div class="hero-bg"></div>
<div class="container">
<!-- Sidebar -->
<aside class="sidebar">
<div class="logo">
<div class="logo-icon">β‘</div>
<span>BareMetalPHP</span>
</div>
<nav>
<div class="nav-section">
<div class="nav-section-title">Getting Started</div>
<a href="#intro" class="nav-link">Introduction</a>
<a href="#installation" class="nav-link">Installation</a>
<a href="#go-server" class="nav-link">Go App Server</a>
</div>
<div class="nav-section">
<div class="nav-section-title">The Basics</div>
<a href="#php-kernel" class="nav-link">PHP Kernel</a>
<a href="#routing" class="nav-link">Routing</a>
<a href="#controllers" class="nav-link">Controllers</a>
<a href="#di" class="nav-link">Dependency Injection</a>
<a href="#views" class="nav-link">Views & Templates</a>
</div>
<div class="nav-section">
<div class="nav-section-title">Database</div>
<a href="#migrations" class="nav-link">Migrations</a>
</div>
<div class="nav-section">
<div class="nav-section-title">Advanced</div>
<a href="#testing" class="nav-link">Testing</a>
<a href="#cli" class="nav-link">CLI Commands</a>
<a href="#architecture" class="nav-link">Architecture</a>
</div>
</nav>
</aside>
<!-- Main Content -->
<main class="main-content">
<!-- Hero -->
<div class="hero">
<h1>β‘ BareMetalPHP</h1>
<p class="hero-subtitle">
Lightning-fast PHP framework powered by Go. Persistent workers, hot reload,
and multi-pool concurrencyβwithout extensions.
</p>
<div class="cta-buttons">
<a href="#installation" class="btn btn-primary">Get Started</a>
<a href="#go-server" class="btn btn-secondary">View Features</a>
</div>
</div>
<!-- Features -->
<div class="feature-grid">
<div class="feature-card">
<div class="feature-icon">π</div>
<h3>Go-Powered Runtime</h3>
<p>Built-in Go application server with persistent PHP workers. No cold starts, no PHP-FPM.</p>
</div>
<div class="feature-card">
<div class="feature-icon">π₯</div>
<h3>Hot Reload</h3>
<p>Automatic file watching and reload. Code changes reflect instantly in development.</p>
</div>
<div class="feature-card">
<div class="feature-icon">β‘</div>
<h3>Multi-Pool Concurrency</h3>
<p>Separate fast and slow worker pools for optimal request handling.</p>
</div>
<div class="feature-card">
<div class="feature-icon">π¦</div>
<h3>Zero Extensions</h3>
<p>Pure PHP and Go. No Swoole, no Octane dependenciesβjust portable performance.</p>
</div>
</div>
<!-- INTRO -->
<section id="intro">
<h2>π― Introduction</h2>
<p>
BareMetalPHP is a modern, lightweight PHP framework built for speed, simplicity, and developer happiness.
It's powered by an optional <strong>Go application server</strong> that enables persistent PHP workers,
hot reload, multi-pool concurrency, and static file acceleration.
</p>
<div class="alert">
<strong>Core Value Proposition</strong>
The Go App Server delivers performance similar to Laravel Octane or Swoole, but simpler,
more portable, and without PHP extensions.
</div>
</section>
<!-- INSTALLATION -->
<section id="installation">
<h2>π¦ Installation</h2>
<h3>Create a New Project</h3>
<pre><code class="language-bash">composer create-project baremetalphp/baremetalphp myapp
cd myapp</code></pre>
<h3>Start the Development Server</h3>
<pre><code class="language-bash">php mini serve</code></pre>
<p>Your application is now running at <span class="inline-code">http://localhost:8000</span></p>
</section>
<!-- GO SERVER -->
<section id="go-server">
<h2>π Go Application Server</h2>
<p>
The BareMetalPHP Go Application Server is a high-performance, production-ready runtime
that replaces traditional PHP-FPM with persistent PHP workers.
</p>
<h3>β¨ Key Features</h3>
<ul>
<li>Persistent PHP workers (no cold starts)</li>
<li>Fast/slow worker classification for optimal load balancing</li>
<li>Automatic hot reload via fsnotify</li>
<li>Static asset acceleration</li>
<li>JSON bridge protocol between Go and PHP</li>
</ul>
<h3>Installation</h3>
<p>Install the Go server scaffold:</p>
<pre><code class="language-bash">php mini go:install
go mod tidy</code></pre>
<h3>Start the Go Runtime</h3>
<pre><code class="language-bash">php mini go:serve</code></pre>
<h3>Configuration</h3>
<p>Edit <span class="inline-code">config/appserver.php</span>:</p>
<pre><code class="language-php">return [
'enabled' => env('APPSERVER_ENABLED', false),
'fast_workers' => env('APPSERVER_FAST_WORKERS', 4),
'slow_workers' => env('APPSERVER_SLOW_WORKERS', 2),
'hot_reload' => env('APPSERVER_HOT_RELOAD', true),
];</code></pre>
<h3>Generated JSON Config</h3>
<pre><code class="language-json">{
"FastWorkers": 4,
"SlowWorkers": 2,
"HotReload": true,
"Static": [
{"Prefix": "/css/", "Dir": "public/css"},
{"Prefix": "/js/", "Dir": "public/js"},
{"Prefix": "/images/", "Dir": "public/images"}
]
}</code></pre>
<h3>Architecture Overview</h3>
<div class="arch-diagram">
<pre><code>ββββββββββββββββ Request βββββββββββββββββββββββββββ
β Browser/CLI β ββββββββββββββββΆ β BareMetalPHP Go Server β
ββββββββββββββββ β β’ Static files β
β β’ Hot reload β
β β’ Worker scheduling β
βββββββββββββββ¬ββββββββββββ
β Dispatch
βΌ
ββββββββββββββββββββββββββββ
β Persistent PHP Workers β
β β’ bootstrap_app.php β
β β’ bridge.php β
βββββββββββββββ¬ββββββββββββ
βΌ
ββββββββββββββββββββββββββββ
β BareMetalPHP Framework β
β β’ Router β
β β’ Kernel β
β β’ DI Container β
β β’ Controllers/Views β
ββββββββββββββββββββββββββββ</code></pre>
</div>
</section>
<!-- PHP KERNEL -->
<section id="php-kernel">
<h2>π§ PHP Kernel</h2>
<p>
The Kernel is the heart of BareMetalPHP. It receives requests from the Go server,
resolves routes, executes controllers, and returns responses.
</p>
<p>
In persistent mode, the kernel bootstraps once and handles multiple requests,
dramatically improving performance over traditional request-per-process models.
</p>
</section>
<!-- ROUTING -->
<section id="routing">
<h2>π£ Routing</h2>
<p>Define your application routes with a clean, expressive syntax:</p>
<pre><code class="language-php">// Simple closure route
$router->get('/', function () {
return "Hello world";
});
// Route with parameters
$router->get('/user/{id}', 'UserController@show');
// Named routes
$router->get('/posts', 'PostController@index')->name('posts.index');
// Route groups
$router->group(['prefix' => 'api'], function ($router) {
$router->get('/users', 'UserController@index');
$router->post('/users', 'UserController@store');
});</code></pre>
</section>
<!-- CONTROLLERS -->
<section id="controllers">
<h2>π Controllers</h2>
<p>Controllers handle your application logic with automatic dependency injection:</p>
<pre><code class="language-php">namespace App\Controllers;
class UserController
{
public function show(\App\Models\User $user)
{
return view('user.show', ['user' => $user]);
}
public function store(Request $request)
{
$user = User::create($request->all());
return redirect()->route('users.show', $user->id);
}
}</code></pre>
<h3>Create a Controller</h3>
<pre><code class="language-bash">php mini make:controller UserController</code></pre>
</section>
<!-- DI -->
<section id="di">
<h2>π§© Dependency Injection</h2>
<p>BareMetalPHP includes a powerful DI container for managing dependencies:</p>
<pre><code class="language-php">// Bind an interface to a concrete implementation
$app->bind(LoggerInterface::class, FileLogger::class);
// Bind a singleton
$app->singleton(Database::class, function ($app) {
return new Database($app['config']['database']);
});
// Resolve from container
$logger = $app->make(LoggerInterface::class);</code></pre>
<p>
Controllers automatically resolve dependencies from the container,
making testing and maintainability simple.
</p>
</section>
<!-- VIEWS -->
<section id="views">
<h2>π¨ Views & Templates</h2>
<p>Render views with a simple, intuitive API:</p>
<pre><code class="language-php">// Return a view
return view('welcome', ['name' => 'Elliot']);
// View with data
return view('posts.index', [
'posts' => Post::all(),
'title' => 'All Posts'
]);</code></pre>
<h3>Template Example</h3>
<pre><code class="language-html"><!-- resources/views/welcome.php -->
<!DOCTYPE html>
<html>
<head>
<title>Welcome</title>
</head>
<body>
<h1>Hello, <?= htmlspecialchars($name) ?>!</h1>
</body>
</html></code></pre>
</section>
<!-- MIGRATIONS -->
<section id="migrations">
<h2>π Database & Migrations</h2>
<p>Manage your database schema with version-controlled migrations:</p>
<h3>Create a Migration</h3>
<pre><code class="language-bash">php mini make:migration create_users_table</code></pre>
<h3>Run Migrations</h3>
<pre><code class="language-bash">php mini migrate</code></pre>
<h3>Rollback Migrations</h3>
<pre><code class="language-bash">php mini migrate:rollback</code></pre>
<h3>Migration Example</h3>
<pre><code class="language-php">use Database\Migration;
return new class extends Migration
{
public function up()
{
$this->schema->create('users', function ($table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamps();
});
}
public function down()
{
$this->schema->drop('users');
}
};</code></pre>
</section>
<!-- TESTING -->
<section id="testing">
<h2>π§ͺ Testing</h2>
<p>BareMetalPHP includes PHPUnit for testing out of the box:</p>
<pre><code class="language-bash">vendor/bin/phpunit</code></pre>
<h3>Test Example</h3>
<pre><code class="language-php">namespace Tests\Feature;
use Tests\TestCase;
class ExampleTest extends TestCase
{
public function test_homepage()
{
$response = $this->get('/');
$response->assertStatus(200);
$response->assertSee('Welcome');
}
}</code></pre>
</section>
<!-- CLI -->
<section id="cli">
<h2>π§ CLI Commands</h2>
<p>The <span class="inline-code">mini</span> CLI provides useful commands for development:</p>
<pre><code class="language-bash"># Start development server
php mini serve
# Go server commands
php mini go:install
php mini go:serve
# Generate code
php mini make:controller UserController
php mini make:migration create_posts_table
# Database
php mini migrate
php mini migrate:rollback
# Run tests
php mini test</code></pre>
</section>
<!-- ARCHITECTURE -->
<section id="architecture">
<h2>π Project Structure</h2>
<p>BareMetalPHP follows a clean, intuitive directory structure:</p>
<pre><code class="language-plaintext">myapp/
βββ app/ # Application code
β βββ Controllers/ # HTTP controllers
β βββ Models/ # Data models
β βββ Middleware/ # HTTP middleware
βββ config/ # Configuration files
β βββ app.php
β βββ database.php
β βββ appserver.php # Go server config
βββ database/ # Database files
β βββ migrations/ # Database migrations
βββ public/ # Web root
β βββ index.php # Entry point
β βββ css/
β βββ js/
β βββ images/
βββ routes/ # Route definitions
β βββ web.php
βββ server/ # Go runtime source
β βββ main.go
βββ php/ # PHP worker files
β βββ bootstrap_app.php
β βββ bridge.php
βββ resources/ # Views and assets
β βββ views/
βββ tests/ # Test suite
βββ vendor/ # Composer dependencies</code></pre>
</section>
</main>
</div>
<script>
hljs.highlightAll();
// Smooth scroll highlight
const sections = document.querySelectorAll("main section");
const navLinks = document.querySelectorAll(".nav-link");
function highlightNav() {
let current = "";
sections.forEach(section => {
const sectionTop = section.offsetTop;
const sectionHeight = section.clientHeight;
if (window.scrollY >= sectionTop - 200) {
current = section.getAttribute("id");
}
});
navLinks.forEach(link => {
link.classList.remove("active");
if (link.getAttribute("href") === `#${current}`) {
link.classList.add("active");
}
});
}
window.addEventListener("scroll", highlightNav);
highlightNav();
</script>
</body>
</html>