SkillAgentSearch skills...

Aphiria

A simple, extensible REST API framework for PHP

Install / Use

/learn @aphiria/Aphiria

README

<p align="center"><a href="https://www.aphiria.com" target="_blank" title="Aphiria"><img src="https://www.aphiria.com/images/aphiria-logo.svg" width="200" height="56"></a></p> <p align="center"> <a href="https://github.com/aphiria/aphiria/actions"><img src="https://github.com/aphiria/aphiria/workflows/ci/badge.svg"></a> <a href="https://coveralls.io/github/aphiria/aphiria?branch=1.x"><img src="https://coveralls.io/repos/github/aphiria/aphiria/badge.svg?branch=1.x" alt="Coverage Status"></a> <a href="https://psalm.dev"><img src="https://shepherd.dev/github/aphiria/aphiria/level.svg"></a> <a href="https://packagist.org/packages/aphiria/aphiria"><img src="https://poser.pugx.org/aphiria/aphiria/v/stable.svg"></a> <a href="https://packagist.org/packages/aphiria/aphiria"><img src="https://poser.pugx.org/aphiria/aphiria/v/unstable.svg"></a> <a href="https://packagist.org/packages/aphiria/aphiria"><img src="https://poser.pugx.org/aphiria/aphiria/license.svg"></a> </p>

Note: This framework is not stable yet.

Introduction

Aphiria is a suite of small, decoupled PHP libraries that make up a REST API framework. It simplifies content negotiation without bleeding into your code, allowing you to write expressive code. Aphiria also provides the following functionality out of the box:

  • <a href="https://www.aphiria.com/docs/1.x/content-negotiation" target="_blank">Automatic content negotiation</a> of your POPOs
  • <a href="https://www.aphiria.com/docs/1.x/routing" target="_blank">One of the fastest, most feature-full routers in PHP</a>
  • <a href="https://www.aphiria.com/docs/1.x/application-builders#basics" target="_blank">A modular way of building your apps from reusable components</a>
  • <a href="https://www.aphiria.com/docs/1.x/authentication" target="_blank">An extensible authentication scheme</a>
  • <a href="https://www.aphiria.com/docs/1.x/authorization" target="_blank">A policy-based authorization control system</a>
  • <a href="https://www.aphiria.com/docs/1.x/dependency-injection" target="_blank">A DI container with binders to simplify configuring your app</a>
  • <a href="https://www.aphiria.com/docs/1.x/validation" target="_blank">A model validator for your POPOs</a>
  • Support for <a href="https://www.aphiria.com/docs/1.x/routing.html#route-attributes" target="_blank">route</a> and <a href="https://www.aphiria.com/docs/1.x/validation" target="_blank">validation</a> attributes
// Define some controller endpoints
class UserController extends Controller
{
    public function __construct(private IUserService $users) {}

    #[Post('/users')]
    public function createUser(User $user): IResponse
    {
        $this->users->create($user);
        
        return $this->created("/users/$user->id", $user);
    }

    #[Get('/users/:id')]
    #[AuthorizeRoles('admin')]
    public function getUserById(int $id): User
    {
        return $this->users->getById($id);
    }
}

// Bind your dependency
$container->bindInstance(IUserService::class, new UserService());

// Run an integration test
$postResponse = $this->post('/users', new User('Dave'));
$user = $this->readResponseBodyAs(User::class, $postResponse);
$admin = new PrincipalBuilder('example.com')
    ->withRoles('admin')
    ->build();
$getResponse = $this->actingAs($admin, fn() => $this->get("/users/$user->id"));
$this->assertParsedBodyEquals($user, $getResponse);

Installation

Create an Aphiria app via Composer:

composer create-project aphiria/app --prefer-dist --stability dev

Refer to the documentation for more details.

Documentation

Full documentation is available at <a href="https://www.aphiria.com" target="_blank">the Aphiria website</a>.

Requirements

  • PHP >= 8.4

Contributing

We appreciate any and all contributions to Aphiria. Please read the documentation to learn how to contribute.

Community

If you have general questions or comments about Aphiria, join our GitHub Discussions.

Directory Structure

Aphiria is organized as a monorepo. Each library is contained in src/{library}, and contains src and tests directories.

License

This software is licensed under the MIT license. Please read the LICENSE for more information.

Author

Aphiria was created and primarily written by David Young.

View on GitHub
GitHub Stars142
CategoryContent
Updated17d ago
Forks5

Languages

PHP

Security Score

100/100

Audited on Mar 17, 2026

No findings