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 apiWhat it provides
Establishing the Vault does two main things:
- Installs
firebase/php-jwtfor token handling. - Publishes a base
APIControllerto yourapp/Controllersdirectory.
Declarative API Responses
Jengo Base leverages PHP 8 attributes to simplify API development. By applying the #[API] attribute to a controller or method, Jengo automatically intercepts the response and formats it into a standardized JSON structure.
php
namespace App\Controllers;
use Jengo\Base\Attributes\API;
#[API]
class ProductController extends BaseController
{
public function index()
{
// This will automatically be returned as JSON
return ['status' => 'success', 'data' => ['name' => 'Jengo Pro']];
}
}