nesto / framework
Nesto — a PHP framework: modules, dependency injection, guards, pipes, interceptors, filters, validation, an ORM and a Prisma-style client, OpenAPI, queues, scheduling and a CLI, all with attributes.
Requires
- php: >=8.3
- ext-json: *
- ext-pdo: *
- league/flysystem: ^3.29
- nyholm/psr7: ^1.8
- nyholm/psr7-server: ^1.1
- psr/container: ^2.0
- psr/event-dispatcher: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.1 || ^2.0
- psr/http-server-handler: ^1.0
- psr/http-server-middleware: ^1.0
- psr/log: ^3.0
- psr/simple-cache: ^3.0
Requires (Dev)
- league/flysystem-aws-s3-v3: ^3.29
- league/flysystem-memory: ^3.29
- phpunit/phpunit: ^11.0
Suggests
- ext-fileinfo: MIME type detection for uploaded files
- ext-pcntl: Graceful shutdown of queue/schedule workers on SIGTERM/SIGINT
- ext-pdo_mysql: MySQL / MariaDB connections (ORM, Prisma client)
- ext-pdo_pgsql: PostgreSQL connections (ORM, Prisma client)
- ext-pdo_sqlite: SQLite connections (ORM, Prisma client)
- league/flysystem-aws-s3-v3: S3 (and S3-compatible: R2, MinIO, Spaces) disks in config/filesystems.php
- league/flysystem-memory: In-memory disks for tests
- spiral/roadrunner-http: Run the application as a RoadRunner worker
Provides
None
Conflicts
None
Replaces
None
README
About Nesto
Nesto is a PHP framework for building APIs with a clear structure. Your application is a tree of modules; each module declares its controllers and the services it provides, and everything is wired together with PHP attributes and constructor injection. Nesto takes care of the plumbing so you can focus on your domain:
- Modules and dependency injection, with singleton, request and transient scopes.
- Guards, pipes, interceptors and exception filters around every request.
- Validation and serialization declared on plain DTO classes.
- An ORM with entities, relations, a query builder and generated migrations, plus a Prisma-style client, on PostgreSQL, MySQL, MariaDB and SQLite.
- File uploads and storage on local disks and S3.
- Queues, task scheduling, events, caching and rate limiting.
- Authentication with JWT and an OpenAPI document generated from your code.
- A console with generators, and production serving in FrankenPHP worker mode.
- Configuration in
.envandconfig/*.php, like Laravel: switch the data layer (ORM_DRIVER=orm|prisma|none), the cache store (CACHE_DRIVER=memory|file|database|redis) and the log channel (LOG_CHANNEL=file|stderr|stdout|stack) without touching code. Every error the framework catches, PHP warnings and fatal errors included, ends up in the log.
Nesto speaks the PHP standards (PSR-7, 11, 15, 3, 14 and 16), so any Composer package plugs in.
Getting Started
composer global require nesto/framework
nesto new my-api
cd my-api
php nesto start
Open http://127.0.0.1:3000/api and you get Hello World!. Make sure Composer's global bin directory
(composer global config bin-dir --absolute) is on your PATH.
If Composer reports a conflict with another global tool (for example psr/http-message locked to an older version),
let it adjust the shared dependencies: composer global require nesto/framework -W.
A controller, a service and a module look like this:
use Nesto\Common\Attributes\{Body, Controller, Get, Injectable, Module, Post}; use Nesto\Validation\Attributes\{IsString, Length}; final class CreateCatDto { #[IsString, Length(min: 2, max: 50)] public string $name; } #[Injectable] final class CatsService { private array $cats = []; public function create(CreateCatDto $dto): array { return $this->cats[] = ['id' => count($this->cats) + 1, 'name' => $dto->name]; } public function findAll(): array { return $this->cats; } } #[Controller('cats')] final class CatsController { public function __construct(private readonly CatsService $cats) {} #[Get] public function findAll(): array { return $this->cats->findAll(); } #[Post] public function create(#[Body] CreateCatDto $dto): array { return $this->cats->create($dto); } } #[Module(controllers: [CatsController::class], providers: [CatsService::class])] final class CatsModule {}
Or let the console write it for you: php nesto g resource cats.
Learning Nesto
The Nesto documentation covers every part of the framework, and its
tutorial builds a complete blog API step by step, from
nesto new to production.
Requirements
- PHP 8.3 or newer, with PDO and the driver of your database (
pdo_pgsql,pdo_mysqlorpdo_sqlite) - Composer 2
Contributing
Thank you for considering contributing to Nesto! Bug reports and pull requests are welcome on GitHub. To work on the framework:
git clone https://github.com/trynesto/framework nesto
cd nesto
composer install
vendor/bin/phpunit
The database tests also run against PostgreSQL, MySQL and MariaDB when NESTO_TEST_PGSQL_URL, NESTO_TEST_MYSQL_URL
and NESTO_TEST_MARIADB_URL point at throwaway databases whose name contains test, and the Redis cache tests when
NESTO_TEST_REDIS_URL is set (e.g. redis://127.0.0.1:6379/15; only keys prefixed nesto_test: are touched). To try a change in an
application, create one against your checkout with bin/nesto new demo --dev.
Security Vulnerabilities
If you discover a security vulnerability within Nesto, please report it privately through GitHub security advisories instead of opening a public issue. All reports will be addressed promptly.
License
The Nesto framework is open-source software licensed under the MIT license.