01 PHP 8.5+ · Zero dependencies

Bare by design.

Barephrame is a PHP framework built for fast, dependency-free API development. Compiled routes and its own ORM. Nothing you didn't ask for, nothing hidden underneath.

  • 0runtime dependencies
  • 3database engines
  • 4iterations of this idea

// philosophy

It shouldn't be required to load thousands of dependencies just to create an API.

That's the whole idea behind Barephrame. The core is small enough to read in an afternoon and simple enough to extend without fighting it — override the parts you need, leave the rest exactly as it is.

02 — Spec sheet

What's in the frame

Four load-bearing decisions the rest of the framework is built around.

Zero dependencies

No package manager required to run the core. What ships is what runs, nothing pulled in behind the scenes.

Its own DB Manager

Connect to Postgres, MySQL, or Firebird through one consistent connection layer.

Fast response times

Routes compile ahead of time via the CLI instead of being resolved fresh on every single request.

Its own ORM

Built specifically for Barephrame, talk to different database engines with a consistent syntax.

03 — Mechanism

Routing lives in attributes

Barephrame reads native PHP attributes to know what an endpoint is, which HTTP method it answers to, and what runs before it. No routing files to keep in sync by hand.

  • #[Route] required. Marks a method as an endpoint, with optional middleware classes as extra arguments.
  • #[Method] optional. Defaults to GET when omitted.
  • #[Version] optional. Prefixes the endpoint with /v{n}.
  • Dynamic segments a :name in the path is passed to the method, in order, as a typed argument.

Changed a route? Run --compile-routes, or keep --watch running while you build.

App/users/Users.php
// /App/users/Users.php
namespace App\users;

use Barephrame\Attributes\Method;
use Barephrame\Attributes\Route;
use Barephrame\Core\Request\Request;

class Users {

    #[Route('/users')]
    public function ListAllUsers() {}

    #[Method('POST')]
    #[Route('/users')]
    public function CreateUser() {}

    #[Route('/users/:code')]
    public function GetUserData(
        Request $request,
        string $code
    ) {}
}

04 — Documentation

Three sheets, start to finish

The documentation is small on purpose. Here's the short version of each sheet — the full set lives in the repository.

04 Other docs

Routing & Attributes

Every endpoint is a plain method carrying a #[Route] attribute. Nothing is discovered until it's compiled — that's what keeps response times down.

  • #[Route('/path')] is required; without it, the method is invisible to the router.
  • #[Method('POST'|'PUT'|'PATCH'|...)] overrides the default of GET.
  • #[Version(n)] prefixes the route with /v{n}.
  • A middleware chain can be passed as extra arguments to #[Route]; the controller only runs once every middleware returns a 200.
  • The Request object is always available as the first parameter, but it's optional to type-hint it.
Read the full Endpoints.md →
Route with middleware
// requires all middlewares to validate correctly before the controller runs
#[Route('/users/:code', JWTMiddleware::class, RoleMiddleware::class)]
#[Version(3)]
public function GetUserData(Request $req, int $code) {}
// resolves to GET /v3/users/:code

Get the frame up

terminal
# clone, scaffold, and compile routes
git clone https://github.com/Angel-del-dev/barephrame-V2.git my-api
cd my-api
php ./Barephrame/cli/tools.php --init --watch