-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathindex.html
More file actions
179 lines (155 loc) · 8.66 KB
/
Copy pathindex.html
File metadata and controls
179 lines (155 loc) · 8.66 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Atom - PHP 8.5 micro‑framework</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<nav id="sidebar">
<h2>Atom</h2>
<a href="index.html#quickstart">Quick start</a>
<a href="index.html#architecture">Architecture</a>
<a href="index.html#config">Config</a>
<a href="index.html#scope">Scope</a>
<h2>Routing</h2>
<a href="routing.html#routing-routes">Route patterns</a>
<a href="routing.html#routing-groups">Groups & middleware</a>
<a href="routing.html#routing-named">URL generation</a>
<a href="routing.html#routing-health">Health check</a>
<a href="routing.html#routing-attributes">Attribute routes</a>
<a href="routing.html#routing-perf">Performance</a>
<h2>WebSocket</h2>
<a href="websocket.html">WebSocket server</a>
<h2>HTTP</h2>
<a href="http.html#http-request">Request</a>
<a href="http.html#http-files">File uploads</a>
<a href="http.html#http-response">Response</a>
<a href="http.html#http-controllers">Controllers</a>
<a href="http.html#http-session">Session</a>
<h2>Testing</h2>
<a href="testing.html#test-client">HTTP Test Client</a>
<h2>Templates</h2>
<a href="templates.html#tpl-syntax">Syntax & filters</a>
<a href="templates.html#tpl-control">Control flow</a>
<a href="templates.html#tpl-raw">Raw blocks</a>
<a href="templates.html#tpl-inherit">Inheritance</a>
<a href="templates.html#tpl-custom">Custom filters & globals</a>
<h2>Validation</h2>
<a href="validation.html#val-dto">DTO definition</a>
<a href="validation.html#val-nested">Nested arrays</a>
<a href="validation.html#val-request">Request validation</a>
<a href="validation.html#val-ref">Attribute reference</a>
<h2>Middleware</h2>
<a href="middleware.html#mw-pipeline">Pipeline</a>
<a href="middleware.html#mw-cors">CORS</a>
<a href="middleware.html#mw-csrf">CSRF</a>
<a href="middleware.html#mw-ratelimit">Rate Limiter</a>
<h2>Container</h2>
<a href="container.html#di-bindings">Bindings</a>
<a href="container.html#di-autowire">Autowiring</a>
<h2>Cache</h2>
<a href="cache.html">Cache API</a>
<h2>ORM</h2>
<a href="orm.html">Eloquent-like ORM</a>
<h2>Reference</h2>
<a href="reference.html#ref-database">Database</a>
<a href="reference.html#ref-logger">Logger</a>
<a href="reference.html#ref-paginator">Paginator</a>
<a href="reference.html#ref-encrypt">Encryption</a>
<a href="reference.html#ref-cli">CLI Console</a>
<a href="reference.html#ref-env">.env & Config</a>
<a href="reference.html#ref-regex">Regex utility</a>
<a href="reference.html#ref-status">Status codes</a>
<a href="index.html#ref-structure">Project structure</a>
</nav>
<div id="main">
<h1>Atom <span>⚛</span></h1>
<p class="meta">PHP 8.5 micro‑framework · PCRE‑powered · 613 tests · zero runtime dependencies</p>
<div class="flex">
<span class="tag">PHP 8.5</span><span class="tag">PCRE</span><span class="tag">JIT regex</span><span class="tag">613 tests</span>
<span class="tag">Property hooks</span><span class="tag">DI</span><span class="tag">Twig-like</span><span class="tag">18 validators</span>
<span class="tag">Rate Limiter</span><span class="tag">Encryption</span><span class="tag">Health check</span>
</div>
<h2 id="quickstart">Quick start</h2>
<pre><code><span class="kw">use</span> Atom\{Application, Config};
<span class="var">$app</span> = <span class="kw">new</span> Application(<span class="kw">new</span> Config(
<span class="str">debug</span>: <span class="kw">true</span>,
<span class="str">viewsDir</span>: __DIR__ . <span class="str">'/../views'</span>,
<span class="str">cacheDir</span>: __DIR__ . <span class="str">'/../storage/cache'</span>,
));
<span class="var">$app</span>->router->get(<span class="str">'/'</span>, <span class="str">'HomeController@index'</span>);
<span class="var">$app</span>->router->group(<span class="str">'/api'</span>, [<span class="str">'auth'</span>], <span class="kw">fn</span>(<span class="var">$r</span>) => {
<span class="var">$r</span>->get(<span class="str">'/users/{id}'</span>, <span class="str">'UserController@show'</span>, <span class="str">'user.show'</span>);
<span class="var">$r</span>->post(<span class="str">'/users'</span>, <span class="str">'UserController@create'</span>);
});
<span class="var">$app</span>->run();</code></pre>
<h2 id="architecture">Architecture</h2>
<div class="grid">
<div class="card"><h4>Config</h4><p>debug, cacheDir, viewsDir, timezone, logLevel, logMaxSize, appName, fromEnv, profiles</p></div>
<div class="card"><h4>Application</h4><p>Boot, container wiring, lazy Session, ws(), wsServer(), cache(), log(), run loop</p></div>
<div class="card"><h4>Container</h4><p>DI: bind, singleton, instance, has, autowire</p></div>
<div class="card"><h4>Router</h4><p>O(1) PCRE dispatch, groups, URL gen, cache, health</p></div>
<div class="card"><h4>Request</h4><p>Property hooks, JSON body, Bearer, _method spoofing</p></div>
<div class="card"><h4>Response</h4><p>html/json/redirect/cookies, CRLF shield, send(isHttps)</p></div>
<div class="card"><h4>Pipeline</h4><p>Onion middleware: closure | object | string</p></div>
<div class="card"><h4>Validator</h4><p>18 attribute rules, filter_var-powered, nested arrays</p></div>
<div class="card"><h4>Session</h4><p>Lazy, get/set/flash/regenerate, CSRF rotation</p></div>
<div class="card"><h4>Encrypt</h4><p>AES-256-GCM encryption utility</p></div>
<div class="card"><h4>HttpClient</h4><p>Fluent test client for route assertions</p></div>
<div class="card"><h4>Logger</h4><p>7 levels, rotate, clear, maxSize autorotation</p></div>
<div class="card"><h4>Cache</h4><p>Array & File drivers, get/set/has/delete/flush, remember, increment/decrement</p></div>
<div class="card"><h4>WebSocket</h4><p>RFC 6455 server, rooms, broadcast, ping/pong, CLI</p></div>
<div class="card"><h4>ORM</h4><p>Eloquent-like: Model, Query builder, relations, eager loading, timestamps</p></div>
</div>
<h2 id="config">Config</h2>
<pre><code><span class="var">$config</span> = <span class="kw">new</span> Config(
<span class="str">debug</span>: <span class="kw">false</span>,
<span class="str">cacheDir</span>: <span class="str">'/tmp/atom'</span>,
<span class="str">viewsDir</span>: __DIR__ . <span class="str">'/templates'</span>,
<span class="str">routeCache</span>: <span class="str">'file'</span>, <span class="cm">// 'file' | 'cache'</span>
<span class="str">viewCache</span>: <span class="str">'file'</span>, <span class="cm">// 'file' | 'cache'</span>
<span class="str">timezone</span>: <span class="str">'Europe/Moscow'</span>,
<span class="str">logFile</span>: <span class="str">'/var/log/app.log'</span>,
<span class="str">logLevel</span>: <span class="num">2</span>, <span class="cm">// WARN</span>
<span class="str">logMaxSize</span>: <span class="num">1_048_576</span>,
<span class="str">appName</span>: <span class="str">'MyApp'</span>,
);
<span class="var">$app</span> = <span class="kw">new</span> Application(<span class="var">$config</span>);</code></pre>
<p>When <code>debug: false</code>, exceptions return empty 500. When <code>debug: true</code>, exceptions are rethrown.</p>
<h2 id="scope">Scope of Application</h2>
<table>
<tr><th>Scenario</th><th>Fit</th></tr>
<tr><td>REST API, microservice, MVP, prototype</td><td>Excellent</td></tr>
<tr><td>Admin panel, static-site backend, SPA backend</td><td>Good</td></tr>
<tr><td>High-traffic API</td><td>Good — O(1) routing, JIT PCRE</td></tr>
<tr><td>Enterprise CMS, WebSocket/real-time</td><td>Good — built-in WsServer</td></tr>
</table>
<h2 id="ref-structure">Project structure</h2>
<pre><code>atom/
├── src/Atom/
│ ├── Config.php
│ ├── Application.php
│ ├── Constants.php
│ ├── Cache/{Cache,Driver,ArrayDriver,FileDriver}.php
│ ├── Console/Console.php
│ ├── Container/Container.php
│ ├── Database/Database.php
│ ├── Http/{Request,Response,Session,StatusCode,UploadedFile}.php
│ ├── Middleware/{MiddlewareInterface,Pipeline,Cors,Csrf,RateLimit}.php
│ ├── Orm/{Model,Query,Table,Column,PrimaryKey,Relation,HasMany,BelongsTo,HasOne}.php
│ ├── Routing/{Route,CompiledRoute,MatchedRoute,RouteCompiler,Router}.php
│ ├── Support/{Regex,Logger,Paginator,Encrypt}.php
│ ├── Test/HttpClient.php
│ ├── Validation/Validator.php (+ 18 attribute classes)
│ ├── View/{Compiler,Engine,Template}.php
│ └── WebSocket/{Connection,Server}.php
├── tests/ <span class="cm"># 613 tests</span>
├── public/index.php
├── docs/index.html
└── composer.json</code></pre>
<footer>Atom — PHP 8.5 micro‑framework · zero runtime dependencies</footer>
</div>
</body>
</html>