Skip to content

Commit 5a53c6b

Browse files
committed
Init chat code import
0 parents  commit 5a53c6b

156 files changed

Lines changed: 6474 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.env.example

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
APP_ENV=local
2+
APP_DEBUG=true
3+
APP_KEY=change-me
4+
5+
SESSION_COOKIE=pipeflow_session
6+
SESSION_SECURE=false
7+
SESSION_SAME_SITE=Lax
8+
9+
DB_DRIVER=sqlite
10+
DB_DATABASE=storage/database.sqlite
11+
DB_HOST=127.0.0.1
12+
DB_PORT=3306
13+
DB_USERNAME=
14+
DB_PASSWORD=

.github/workflows/ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Set up PHP
13+
uses: shivammathur/setup-php@v2
14+
with:
15+
php-version: '8.3'
16+
extensions: pdo, json, mbstring
17+
- name: Install dependencies
18+
run: composer install --no-interaction --prefer-dist
19+
- name: Lint
20+
run: find src app bootstrap public routes -name '*.php' -print0 | xargs -0 -n 1 php -l
21+
- name: PHPUnit
22+
run: composer test

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/vendor/
2+
/.env
3+
/storage/
4+
/.phpunit.cache/
5+
/coverage/
6+
7+
# OS
8+
.DS_Store
9+
Thumbs.db

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 PipeFlow
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# PipeFlow
2+
3+
PipeFlow is a pragmatic PHP **8.5+** framework that leans hard into **functional composition** (pipeline style) while still giving you familiar MVC ergonomics (controllers, models, views, migrations) + a CLI scaffold.
4+
5+
## Quickstart
6+
7+
```bash
8+
composer install
9+
cp .env.example .env
10+
php pipeflow serve
11+
```
12+
13+
Open: `http://127.0.0.1:8000`
14+
15+
## Documentation
16+
17+
- Main docs: `docs/README.md`
18+
- Architecture overview: `docs/ARCHITECTURE.md`
19+
- Per-file reference: `docs/reference/`
20+
- Codex / AI contributor notes: `docs/CODEX.md`
21+
22+
## Routing
23+
24+
Routes live in `routes/web.php`:
25+
26+
```php
27+
$router = app(\PipeFlow\Router\Router::class);
28+
$router->get('/', [\App\Controllers\HomeController::class, 'index'], 'home');
29+
```
30+
31+
### Conn + Plugs (Phoenix-inspired)
32+
33+
PipeFlow now supports Phoenix-ish request flow using a `Conn` object and a plug pipeline.
34+
35+
- `PipeFlow\Http\Conn` carries Request, Response, session, assigns, etc.
36+
- Plugs implement `PipeFlow\Plug\Contracts\PlugInterface` and are composed via `PlugStack`.
37+
- Built-in plugs: `SessionPlug`, `CsrfPlug` (enabled by default in the Kernel).
38+
39+
Write a route handler that receives a Conn:
40+
41+
```php
42+
use PipeFlow\Http\Conn;
43+
44+
$router->get('/hello', function (Conn $conn) {
45+
return $conn->assign('name', 'world')->render('hello');
46+
});
47+
```
48+
49+
## Views
50+
51+
`view('welcome', ['title' => 'PipeFlow'])` renders `resources/views/welcome.php`.
52+
53+
## Models
54+
55+
Create a model:
56+
57+
```bash
58+
php pipeflow make:model Post --migration
59+
```
60+
61+
Base model lives at `PipeFlow\Database\Model`.
62+
63+
## Migrations
64+
65+
```bash
66+
php pipeflow migrate
67+
php pipeflow migrate:rollback --steps=1
68+
```
69+
70+
Migrations live in `database/migrations`.
71+
72+
## Functional pipeline
73+
74+
Use the global `pipe()` helper:
75+
76+
```php
77+
$result = pipe('hello',
78+
fn($s) => strtoupper($s),
79+
fn($s) => $s . ' WORLD'
80+
);
81+
```
82+
83+
## License
84+
85+
MIT

app/Controllers/HomeController.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Controllers;
6+
7+
use PipeFlow\Http\Request;
8+
use PipeFlow\Http\Response;
9+
10+
final class HomeController
11+
{
12+
public function index(Request $request): Response
13+
{
14+
return view('welcome', [
15+
'title' => 'PipeFlow',
16+
'message' => 'Framework skeleton is live. Try: php pipeflow route:list',
17+
]);
18+
}
19+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Web\Controllers;
6+
7+
use PipeFlow\Http\Conn;
8+
9+
/**
10+
* Example controller using Conn-style handlers (Phoenix-ish).
11+
*/
12+
final class HomeController
13+
{
14+
public function index(Conn $conn): Conn
15+
{
16+
return $conn->render('welcome', [
17+
'title' => 'PipeFlow',
18+
'message' => 'Phoenix-ish router pipelines + flash + session are wired. Try: php pipeflow route:list',
19+
]);
20+
}
21+
}

app/Web/Endpoint.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace App\Web;
6+
7+
use PipeFlow\Foundation\Application;
8+
use PipeFlow\Router\Router;
9+
10+
/**
11+
* Endpoint (Phoenix analogue)
12+
*
13+
* Central place to wire the HTTP entrypoint:
14+
* - global plugs (run for every request)
15+
* - router definition (pipelines/scopes/routes)
16+
*
17+
* In Phoenix, Endpoint also handles static assets, code reloading, sockets, etc.
18+
* PipeFlow keeps this lightweight and adapter-friendly.
19+
*/
20+
final class Endpoint
21+
{
22+
/**
23+
* Global plugs applied to every request (before the router / per-route pipelines).
24+
*
25+
* @return array<int, string|object|callable>
26+
*/
27+
public function plugs(Application $app): array
28+
{
29+
// Keep this minimal. Put Session/CSRF into the "browser" pipeline in RouterDefinition.
30+
return [];
31+
}
32+
33+
/**
34+
* Register pipelines, scopes and routes.
35+
*/
36+
public function boot(Application $app): void
37+
{
38+
/** @var Router $router */
39+
$router = $app->container()->get(Router::class);
40+
RouterDefinition::register($router, $app);
41+
}
42+
}

0 commit comments

Comments
 (0)