PHPackages                             enicore/ravenapi - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. enicore/ravenapi

ActiveLibrary[API Development](/categories/api)

enicore/ravenapi
================

API framework.

v3.1(1y ago)03MITHTMLPHP ^8.3

Since Nov 11Pushed 1y ago1 watchersCompare

[ Source](https://github.com/enicore/ravenapi)[ Packagist](https://packagist.org/packages/enicore/ravenapi)[ RSS](/packages/enicore-ravenapi/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Raven API Framework
===================

[](#raven-api-framework)

Raven API is a lightweight PHP framework for building APIs quickly and efficiently. It provides essential tools for handling requests, managing sessions, interacting with databases, routing, and more, all wrapped in a modular structure ideal for API development.

Installation
------------

[](#installation)

```
composer require enicore/ravenapi
```

To copy from a local directory, add the following configuration in your composer.json:

```
{
    "repositories": [
        {
            "type": "path",
            "url": "path/to/ravenapi",
            "options": {
                "symlink": false
            }
        }
    ],
    "require": {
        "enicore/ravenapi": "*"
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}
```

Usage
-----

[](#usage)

In `index.php`, initialize the program:

```
const API_DIR = __DIR__ . "/";
require __DIR__ . "/vendor/autoload.php";

Enicore\RavenApi\Database::instance([
    "host" => "db_host",
    "port" => "db_port",
    "username" => "db_username",
    "password" => "db_password",
    "database" => "db_database",
    "options" => [],
]);

Enicore\RavenApi\App::instance()->run();
```

### Directory structure

[](#directory-structure)

Classes will be auto-loaded according to their namespaces relative to `APP_DIR`. For example:

```
Controllers\DashboardController -> APP_DIR/controllers/DashboardController.php
Models\User -> APP_DIR/models/User.php

```

### Routing

[](#routing)

The requests will be routed to controllers based on the POST or GET values: "controller" and "action". For example:

```
https://api.com?controller=dashboard&action=getpage

```

Controllers will be loaded from the `Controllers` namespace. Their class names must be suffixed with `Controller`, and the action methods must be suffixed with `Action`. For example:

```
namespace Controllers;

class DashboardController extends \Enicore\RavenApi\Controller
{
    public function getPageAction(): array
```

Parameters can be obtained by using the `Request` class, for example:

```
$id = $this->request->get('id');
$id = $this->request->getDecodedId(); // retrieve and decode the encoded id
$all = $this->request->all();
```

The controller action should return an array of parameters that will be passed back to the frontend:

```
public function getPageAction(): array
{
    return ["hello" => "world"];
}
```

The above result will be returned as:

```
{
    "success": true,
    "data": {
        "hello": "world"
    }
}
```

You can also use the `Response` class to send the same response:

```
$this->response->success(["hello" => "123"]);
```

To send an error response, use the `error()` method (with optional data that can be passed as the second parameter):

```
$this->response->error("Cannot save record.");
```

Error responses are returned with header 200 just like successful responses, but with the "success" parameter set to false. The above response will be returned as:

```
{
    "success": false,
    "message": "Cannot save record.",
    "data": []
}
```

### Authentication

[](#authentication)

By default, all routes require authentication. To allow access to a route without authentication, add the `#[NoAuth]` annotation to the method:

```
#[NoAuth]
public function getPageAction(): array
```

### Dependency Injection

[](#dependency-injection)

To use dependency injection in your classes, use the `Injection` trait:

```
class MyClass
{
    use Injection;
```

This will make all the framework singletons directly available in the class. The injected classes will be created on first access. Controllers inheriting from `Enicore\RavenApi\Controller` and Models inheriting from `Enicore\RavenApi\Model` already use the `Injection` trait.

```
$this->auth     => Enicore\RavenApi\Auth;       // Auth service
$this->code     => Enicore\RavenApi\Code;       // Encoding and encryption
$this->db       => Enicore\RavenApi\Database;   // Database service
$this->request  => Enicore\RavenApi\Request;    // Request handling
$this->response => Enicore\RavenApi\Response;   // Response handling
$this->router   => Enicore\RavenApi\Router;     // Router service
$this->session  => Enicore\RavenApi\Session;    // Session management
```

Injection is done using the magic `__get()` method. If your class already uses this method for other purposes, you can inject the dependencies manually calling `$this->injectDependencies()` in the constructor of the class. In this case, all the dependencies will be created right away.

```
class MyClass
{
    use Injection;

    public function __construct()
    {
        $this->injectDependencies();
    }

    public function __get(string $variable): string
    {
        return "something";
    }
}
```

To access the dependencies directly, use their `instance()` method, for example:

```
use Enicore\RavenApi\Database;
Database::instance()->getFirst("...");
```

License
-------

[](#license)

Raven API is licensed under the MIT License. See LICENSE for more information.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

553d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6da9892eed0c0763fcbbeabeb8b9cbe68b3a4a57900548f624aee45cdaaea637?d=identicon)[enicore](/maintainers/enicore)

---

Top Contributors

[![enicore-dev](https://avatars.githubusercontent.com/u/183366198?v=4)](https://github.com/enicore-dev "enicore-dev (1 commits)")

### Embed Badge

![Health badge](/badges/enicore-ravenapi/health.svg)

```
[![Health](https://phpackages.com/badges/enicore-ravenapi/health.svg)](https://phpackages.com/packages/enicore-ravenapi)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
