Laravel backend generator: schema to REST API

Auxen, by Auxen Prime, generates a Laravel (PHP) backend from your database schema or a plain-English description. The output is an ordinary Laravel project that you download and own. Install with Composer and serve it with Artisan.

What you get

The table is read from a real generated project (142 files for the example schema). The last column is the file in that project.

AreaWhat is generatedWhere in the project
REST APICreate, read, update and delete endpoints for each entity, under /api/<entity>app/Http/Controllers/CustomerController.php
AuthenticationRegistration and login with JWT in this example. The builder also offers OAuth2, Session, API Key, Basic Auth and OpenID Connect.app/Http/Controllers/AuthController.php
RBACRole and permission tables, and a permission check on the protected routesapp/Http/Middleware/CheckPermission.php
MigrationsAn initial migration for the schemadatabase/migrations/create_customer_table.php, database/migrations/create_invoice_table.php
Tests3 test files in the example (unit and integration)tests/Feature/SessionFlowTest.php
DockerfileBuilds the image and runs the app as a non-root user (uid 10001)Dockerfile
docker-composeRuns the app with a PostgreSQL database beside itdocker-compose.yml
CI pipelineA GitHub Actions workflow, when you choose it.github/workflows/ci.yml
API descriptionAn OpenAPI description of the APIapp/Http/Controllers/OpenApiController.php
Health checkA health endpointroutes/api.php
ConfigurationAn .env.example listing the settings.env.example

The example it was generated from

Entities Customer and Invoice, with Invoice many-to-one Customer, on PostgreSQL, JWT with RBAC. Options: unit tests, integration tests, Docker, GitHub Actions pipeline and migrations. Auxen adds the authentication tables (users, roles, permissions, sessions and others) around them.

Folder layout, with file counts
.github/workflows/  1 file
app/  83 files
app/Exceptions/  1 file
app/Http/  49 files
app/Models/  13 files
app/Providers/  1 file
app/Queries/  13 files
app/Services/  6 files
bootstrap/  3 files
bootstrap/cache/  1 file
config/  4 files
database/  22 files
database/migrations/  21 files
database/seeders/  1 file
docs/  2 files
public/  1 file
routes/  4 files
storage/  7 files
storage/app/  2 files
storage/framework/  4 files
storage/logs/  1 file
tests/  5 files
tests/Feature/  3 files
(project root)  10 files

Real excerpts

A generated controller app/Http/Controllers/CustomerController.php
class CustomerController extends Controller implements HasMiddleware
{
    public static function middleware(): array
    {
        return [
            'jwt.auth',
            new Middleware('permission:CUSTOMER_READ', only: ['index', 'show']),
            new Middleware('permission:CUSTOMER_CREATE', only: ['store']),
            new Middleware('permission:CUSTOMER_UPDATE', only: ['update']),
            new Middleware('permission:CUSTOMER_DELETE', only: ['destroy']),
        ];
    }

    public function index(Request $request): JsonResponse
The RBAC check app/Http/Middleware/CheckPermission.php
class CheckPermission
{
    public function handle(Request $request, Closure $next, string ...$permissions): Response
    {
        $user = $request->user();

        if (!$user) {
            return response()->json(['message' => 'Unauthorized'], 401);
        }

        $userPermissions = $user->getPermissions();
The first migration, for Customer database/migrations/create_customer_table.php
Schema::create('customer', function (Blueprint $table) {
    $table->uuid('customer_id')->primary();
    $table->string('customer_name');
    $table->string('customer_email')->unique();
    $table->string('customer_birthday')->nullable();
    $table->boolean('customer_active');
    $table->string('customer_gender');
    $table->text('customer_notes')->nullable();
    $table->timestamp('created_at')->useCurrent();
    $table->timestamp('updated_at')->nullable();
The Dockerfile Dockerfile
FROM php:8.2-cli-bookworm
RUN apt-get update && apt-get upgrade -y --no-install-recommends \
    && apt-get install -y --no-install-recommends libzip-dev libonig-dev unzip \
    && docker-php-ext-install zip mbstring bcmath \
    && apt-get clean && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y --no-install-recommends libpq-dev unzip \
    && docker-php-ext-install pdo pdo_pgsql \
    && apt-get clean && rm -rf /var/lib/apt/lists/*
COPY --from=composer:2.8 /usr/bin/composer /usr/bin/composer
WORKDIR /var/www
COPY . .
RUN composer install --no-dev
# Run as an unprivileged user (uid and gid 10001) that owns /var/www.
RUN groupadd --system --gid 10001 app && useradd --system --no-create-home --gid app --uid 10001 app && chown -R app:app /var/www
USER 10001:10001
EXPOSE 8000
A generated test tests/Feature/SessionFlowTest.php
class SessionFlowTest extends TestCase
{
    use RefreshDatabase;

    private string $email = 'flow@example.com';
    private string $password = 'Passw0rd!Flow';

    protected function setUp(): void
    {
        parent::setUp();
        config(['jwt.cookie_transport' => false]);
        $this->postJson('/api/auth/register', [

What it is built on

Read from the generated manifest: Laravel (composer.json), Laravel Sanctum (composer.json), PHPUnit (composer.json).

Databases

Laravel generates for PostgreSQL, MySQL, MariaDB, SQLite and Amazon Redshift. It does not generate for MongoDB, Oracle and SQL Server.

How the generator is tested

These checks live in the Auxen repository and run against the generators themselves. They are listed here as what they do, not as a guarantee about every schema you might write.

  • Generation test (npm run test:gen): generates this stack for several example schemas, then checks the syntax of the result with PHP.
  • Runtime test (npm run test:runtime): starts the generated application, connects it to a real database, registers a user, logs in, then creates and lists records over HTTP.
  • Security scan: the generated project, including its Dockerfile and CI files, is scanned with Trivy for vulnerabilities, secrets and misconfiguration. The check fails on any secret, and on any high or critical finding that has a fix.
  • Docker build test (npm run test:docker, run on demand): builds each stack's own Dockerfile.

Running and deploying it

Install with Composer and serve it with Artisan. You download the project and deploy it wherever you run software. Auxen does not deploy the generated backend for you yet. It has a hosted sandbox where you can run the code and try its API before you download it.

Review the code before it carries real traffic, as you would any code you did not write. The terms of service say the same: generated code is provided as is, and you are responsible for reviewing, testing and securing it.

More

Auxen is made by Auxen Prime Technologies Limited and lives at auxenprime.com. It is not affiliated with other companies that use the name Auxen.