hideyukimori / nene2
PHP micro-framework: JSON APIs first, minimal server HTML, easy React/SPA integration, structure friendly to AI tooling.
Requires
- php: >=8.4.1 <9.0
- monolog/monolog: ^3.0
- nyholm/psr7: ^1.8
- nyholm/psr7-server: ^1.1
- psr/container: ^2.0
- psr/http-server-handler: ^1.0
- psr/http-server-middleware: ^1.0
- psr/log: ^3.0
- vlucas/phpdotenv: ^5.6
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^13.1
- robmorgan/phinx: ^0.16.11
- symfony/yaml: ^8.0
Suggests
- symfony/yaml: Required to run validate-mcp-tools.php from a consumer project (add to your require-dev)
- dev-main
- v1.5.329
- v1.5.328
- v1.5.327
- v1.5.323
- v1.5.114
- v1.5.113
- v1.5.112
- v1.5.111
- v1.5.110
- v1.5.109
- v1.5.108
- v1.5.107
- v1.5.106
- v1.5.105
- v1.5.104
- v1.5.103
- v1.5.102
- v1.5.101
- v1.5.100
- v1.5.99
- v1.5.98
- v1.5.97
- v1.5.96
- v1.5.95
- v1.5.94
- v1.5.93
- v1.5.92
- v1.5.91
- v1.5.90
- v1.5.89
- v1.5.88
- v1.5.87
- v1.5.86
- v1.5.85
- v1.5.84
- v1.5.83
- v1.5.82
- v1.5.81
- v1.5.80
- v1.5.79
- v1.5.78
- v1.5.77
- v1.5.76
- v1.5.75
- v1.5.74
- v1.5.73
- v1.5.72
- v1.5.71
- v1.5.70
- v1.5.69
- v1.5.68
- v1.5.67
- v1.5.66
- v1.5.65
- v1.5.64
- v1.5.63
- v1.5.62
- v1.5.61
- v1.5.60
- v1.5.59
- v1.5.58
- v1.5.57
- v1.5.56
- v1.5.55
- v1.5.54
- v1.5.53
- v1.5.52
- v1.5.51
- v1.5.50
- v1.5.49
- v1.5.48
- v1.5.47
- v1.5.46
- v1.5.45
- v1.5.44
- v1.5.43
- v1.5.42
- v1.5.41
- v1.5.40
- v1.5.39
- v1.5.38
- v1.5.37
- v1.5.36
- v1.5.35
- v1.5.34
- v1.5.33
- v1.5.32
- v1.5.31
- v1.5.30
- v1.5.29
- v1.5.28
- v1.5.27
- v1.5.26
- v1.5.25
- v1.5.24
- v1.5.23
- v1.5.22
- v1.5.21
- v1.5.20
- v1.5.19
- v1.5.18
- v1.5.17
- v1.5.16
- v1.5.15
- v1.5.14
- v1.5.13
- v1.5.12
- v1.5.11
- v1.5.10
- v1.5.9
- v1.5.8
- v1.5.7
- v1.5.6
- v1.5.5
- v1.5.4
- v1.5.3
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.0
- v1.2.0
- v1.1.0
- v1.0.0
- v0.8.0
- v0.7.0
- v0.6.0
- v0.5.0
- v0.4.0
- v0.3.0
- v0.2.0
- v0.1.3
- v0.1.2
- v0.1.1
- v0.1.0
- dev-dependabot/npm_and_yarn/frontend/typescript-eslint-8.60.1
- dev-dependabot/npm_and_yarn/frontend/vitest-4.1.8
- dev-dependabot/npm_and_yarn/frontend/multi-b0dfc253ff
- dev-dependabot/npm_and_yarn/frontend/vite-8.0.16
- dev-dependabot/composer/phpstan/phpstan-2.2.2
- dev-dependabot/composer/friendsofphp/php-cs-fixer-3.95.4
- dev-dependabot/npm_and_yarn/frontend/eslint-10.4.1
- dev-dependabot/npm_and_yarn/frontend/typescript-eslint-8.60.0
- dev-dependabot/composer/phpunit/phpunit-13.1.13
- dev-dependabot/composer/phpstan/phpstan-2.2.1
- dev-dependabot/composer/symfony/yaml-8.1.0
- dev-dependabot/composer/friendsofphp/php-cs-fixer-3.95.3
- dev-docs/sidebar-all-howto
- dev-ci/fix-docs-oom-v4
- dev-ci/fix-docs-oom-v3
- dev-ci/fix-docs-oom-v2
- dev-ci/fix-docs-oom
- dev-docs/1283-translate-howto-de-final-complete
- dev-docs/1283-translate-howto-de-final
- dev-docs/1283-translate-howto-de-c
- dev-docs/1283-translate-howto-de-b
- dev-docs/1283-translate-howto-de-a
- dev-docs/1283-translate-howto-de
- dev-docs/1284-translate-howto-fr
- dev-docs/1285-translate-howto-ja
- dev-docs/1287-translate-howto-zh
This package is auto-updated.
Last update: 2026-06-08 01:09:27 UTC
README
PHP micro-framework: JSON APIs first, minimal server HTML, easy React starter integration, structure friendly to AI tooling.
OpenAPI contract — machine-readable API spec (OpenAPI 3.1). Live Swagger UI at http://localhost:8080/docs/ after docker compose up -d app.
NENE2 is a small, modern PHP framework foundation designed for projects that want to ship JSON APIs quickly, keep server-rendered HTML thin, and add a React frontend starter without turning the backend into frontend build glue.
The v1.x foundation covers full Note/Tag CRUD, Bearer JWT auth, pagination helpers, and a six-language VitePress documentation site, with opt-in rate limiting and database health checks as production-ready opt-in features. A maintainer can clone the repository, run a local API, share an OpenAPI contract, expose safe MCP tools through the API boundary, and verify database behavior in Docker Compose.
Theme
- API first: define behavior through clear HTTP boundaries and OpenAPI contracts.
- Simple HTML: keep server HTML minimal, predictable, and easy to replace with SPA shells.
- Frontend ready: provide a React + TypeScript starter direction while keeping the frontend layer replaceable.
- AI readable: prefer explicit directories, small classes, typed boundaries, and documented decisions.
- LLM delivery ready: keep API, MCP, auth, database, and handoff docs aligned for small client-style projects.
- Modern PHP: use strict types, PSR-oriented style, dependency injection, automated tests, and static analysis.
Current Capabilities
The foundation currently includes:
- PSR-7 / PSR-15 / PSR-17 HTTP runtime with explicit routing and middleware.
- OpenAPI contract, Swagger UI, and runtime contract tests for shipped JSON endpoints.
- RFC 9457 Problem Details error responses.
- Typed app and database configuration through
.envloading boundaries. - PSR-11 dependency injection with explicit runtime service wiring.
- PDO connection, query executor, transaction manager, SQLite tests, and opt-in MySQL verification through Docker Compose.
- Bearer JWT middleware with allowlist, blocklist, and prefix path options;
CompositeAuthMiddlewarefor three-tier access models (public / Bearer / API key). - API-key middleware with path and method filters for machine-client endpoints.
- Server-rendered HTML via
NativePhpViewRendererandHtmlResponseFactory— thin HTML coexists with JSON API routes. - Local MCP server support for read/write tools aligned with OpenAPI, with an authentication guard on write operations.
- React + TypeScript + Vite starter kept optional and decoupled from backend runtime behavior.
Installation
NENE2 is available on Packagist.
The recommended way to start a new project is to clone the repository directly — it ships with Docker, .env.example, and all configuration you need out of the box:
git clone https://github.com/hideyukiMORI/NENE2.git my-project
cd my-project
If you want to use NENE2 as a Composer dependency in an existing project:
composer require hideyukimori/nene2
Quick Start
Build the PHP runtime, install dependencies, and run the standard backend checks:
cp .env.example .env docker compose build docker compose run --rm app composer install docker compose run --rm app composer check
Start the local web runtime:
docker compose up -d app
The web entry point is served from public_html/ at http://localhost:8080/.
Useful local URLs:
- API health:
http://localhost:8080/health - Example endpoint:
http://localhost:8080/examples/ping - OpenAPI:
http://localhost:8080/openapi.php - Swagger UI:
http://localhost:8080/docs/
Run optional real MySQL verification when database adapter behavior should be checked against a service database:
docker compose up -d mysql docker compose run --rm app composer test:database:mysql
Domain Layer Example
src/Example/Note/ and src/Example/Tag/ are reference implementations — they demonstrate how to use the framework, but are not part of the public API stability guarantee (see ADR 0009). Copy and adapt the patterns into your own application; do not import these classes as library dependencies.
src/Example/Note/ implements a full Note CRUD with:
| Layer | File(s) |
|---|---|
| Route + handler | GetNoteByIdHandler, CreateNoteHandler, UpdateNoteHandler, DeleteNoteHandler, ListNotesHandler |
| Use case (domain) | GetNoteByIdUseCase, CreateNoteUseCase, UpdateNoteUseCase, DeleteNoteUseCase, ListNotesUseCase |
| Repository interface | NoteRepositoryInterface |
| PDO adapter | PdoNoteRepository |
| Exception mapping | NoteNotFoundException → NoteNotFoundExceptionHandler → 404 Problem Details |
| OpenAPI | docs/openapi/openapi.yaml — GET/POST/PUT/DELETE /examples/notes paths |
| Tests | tests/Example/Note/ — unit, HTTP-level, PDO integration |
All Note endpoints are live at http://localhost:8080/examples/notes after docker compose up -d app.
Development Principles
NENE2 optimizes for fast, calm development. The codebase should be easy for a solo developer, a team, or an AI agent to understand without hidden conventions.
- Keep domain and use-case code decoupled from HTTP, database, template, and CLI details.
- Use PSR-7 / PSR-15 / PSR-17 as the HTTP runtime direction.
- Use PSR-11 as the DI boundary, with explicit wiring first.
- Use typed config objects at runtime; keep
.envat the loading boundary. - Make behavior testable before adding framework magic.
- Treat OpenAPI as the public API contract and keep MCP integrations behind the same API boundary.
- Keep template engines optional; server HTML should stay thin and replaceable.
- Prefer small, boring primitives over clever abstractions.
- Record workflow, roadmap, and implementation decisions in
docs/rather than only in chat.
Repository Layout
NENE2 uses a single repository with Composer at the root, PHP framework code in src/, tests in tests/, a web document root in public_html/, and optional React + TypeScript frontend source in frontend/.
.
├── composer.json
├── src/ # NENE2 framework core
│ ├── Auth/
│ ├── Config/
│ ├── Database/
│ ├── DependencyInjection/
│ ├── Error/
│ ├── Http/
│ ├── Log/
│ ├── Mcp/
│ ├── Middleware/
│ ├── Routing/
│ ├── Validation/
│ ├── View/
│ ├── Example/Note/ # canonical domain layer example (full CRUD)
│ └── Example/Tag/ # second entity example
├── tests/ # PHPUnit / architecture / contract tests
├── config/ # framework default config or examples
├── database/ # migrations, seeds, and schema docs
├── templates/ # native PHP templates and thin server HTML source
├── public_html/ # web document root
│ └── assets/ # built frontend assets
├── frontend/ # React/TypeScript/Vite source
│ └── src/
├── docs/
├── LICENSE
└── README.md
See docs/development/project-layout.md for the design details and placement rules.
Development Commands
For a full step-by-step walkthrough from clone to running API, see docs/development/setup.md.
NENE2 targets PHP >=8.4.1 <9.0. Docker is the standard development runtime, so the host OS does not need to provide that PHP version.
docker compose run --rm app composer check
Composer lives at the repository root and provides the first backend verification commands:
composer validate
composer test
composer analyse
composer check
composer test:database
composer test:database:mysql
See docs/development/php-runtime.md and docs/development/docker.md for runtime and tooling details.
NENE2's quality baseline includes PHP-CS-Fixer for backend style checks and npm, ESLint, TypeScript, and Prettier for the React frontend starter. The frontend starter targets active Node.js LTS, commits package-lock.json, and keeps dependencies modern through update automation. Framework public APIs should use PHPDoc or TSDoc where comments explain contracts or extension rules. See docs/development/quality-tools.md, docs/development/frontend-integration.md, and docs/development/documentation-comments.md.
How-to guides
256 task-focused guides covering authentication, security, database patterns, API design, background jobs, and 100+ product feature recipes.
Common entry points:
- Add a custom route
- Add a database-backed endpoint
- Add JWT authentication
- Add pagination
- Add rate limiting
- Deploy to production
Reference Implementations
hideyukiMORI/NENE2-examples — 93 field-trial applications built with hideyukimori/nene2 as a Composer dependency. Each directory is a self-contained, runnable JSON API corresponding to one howto guide.
git clone https://github.com/hideyukiMORI/NENE2-examples.git cd NENE2-examples/deduplog # or any other example composer install vendor/bin/phpunit
Delivery Starter Docs
Start with these docs when adapting NENE2 for a small client-style API:
- Direction:
docs/integrations/llm-delivery-starter.md - Client project start guide:
docs/development/client-project-start.md - Endpoint workflow:
docs/development/endpoint-scaffold.md - Local MCP server:
docs/integrations/local-mcp-server.md - Local MCP client configuration:
docs/integrations/local-mcp-client-configuration.md - MCP tool policy:
docs/integrations/mcp-tools.md - Authentication boundary:
docs/development/authentication-boundary.md - Machine-client smoke workflow:
docs/development/machine-client-smoke.md - Database test strategy:
docs/development/test-database-strategy.md - Patch release policy:
docs/development/release-v0.1.x-policy.md
Public field trial reference (optional): hideyukiMORI/sakura-exhibition-nene2-field-trial — client-style demo forked from v0.1.1 with exhibition-shaped read-only APIs, OpenAPI, tests, local MCP, and field-trial reports. Not affiliated with any real event; see that repository’s README.md.
Project Workflow
NENE2 uses GitHub Issues as the source of work and local Markdown files as the project memory.
- Create or reuse a focused GitHub Issue.
- Create an Issue-numbered branch from
main, such asdocs/1-initial-governance. - Update code and docs together, keeping the change small.
- Commit with Conventional Commits and include the Issue number.
- Push, open a PR, merge after checks, and return local
mainto a clean state.
See docs/CONTRIBUTING.md, docs/workflow.md, and AGENTS.md before changing the project.
AI / LLM Integration
NENE2 is designed to be AI-readable and usable as a tool by AI agents.
llms.txt— machine-readable project summary for LLM crawlers (llmstxt.org standard).- Smithery — NENE2 MCP server listed in the Smithery registry (
smithery.yaml). - AGENTS.md — entry point for AI agents working in this repository.
- OpenAPI contract —
GET /openapi.phpordocs/openapi/openapi.yaml— the authoritative API contract for LLM tool use. - Local MCP server —
composer mcpvalidates the MCP tool catalog;docker compose run --rm -e NENE2_LOCAL_API_BASE_URL=http://app app php tools/local-mcp-server.phpstarts the local server. - Reference implementations — hideyukiMORI/NENE2-examples: 93 runnable field-trial apps covering every major howto pattern (auth, security, queues, social features, and more). Each app is
composer install && phpunit-ready.
License
NENE2 is released under the MIT License.