The Vault (API Suite)
"The Vault" provides a professional API foundation for Jengo applications, coming complete with JWT support and standardized JSON responses.
Installation
Include the Vault during project creation:
bash
jengo new my-app --apiOr add it to an existing project:
bash
php spark jengo:setup apiOr install directly via composer and run:
bash
php spark jengo:install apiWhat it provides
Configuring the API suite:
- Installs and configures
jengo/apifor automatic schema-backed REST routing, batch actions, and OpenAPI docs. - Publishes
app/Config/JengoApi.phpand connects routes inapp/Config/Routes.php.
Declarative API Responses
Jengo API leverages PHP 8 attributes to simplify custom API development. By applying the #[API] attribute to any controller or method, Jengo automatically intercepts the response and formats it into a standardized JSON structure.
php
namespace App\Controllers;
use Jengo\Api\Attributes\API;
#[API]
class ProductController extends BaseController
{
public function index()
{
// This will automatically be returned as JSON
return ['status' => 'success', 'data' => ['name' => 'Jengo Pro']];
}
}