Getting Started

Quickstart

Build your first API

Get your first Glueful API running.

Prerequisites

  • PHP 8.2 or higher
  • Composer 2+
  • SQLite (included with PHP)

Installation

# Clone the API skeleton
composer create-project glueful/api-skeleton my-api
cd my-api

# Install dependencies
composer install

# Initialize the application
php glueful install --quiet

# Start the development server
php glueful serve

Your API is now running at http://127.0.0.1:8080

Your First Endpoint

Create a simple "Hello World" endpoint in routes/api.php:

<?php

// $router is provided by the route bootstrap context
use Glueful\Http\Response;

$router->get('/hello', function() {
    return new Response([
        'message' => 'Hello, Glueful!',
        'timestamp' => date('c')
    ]);
});

Test it:

curl http://127.0.0.1:8080/hello

Built-in CRUD APIs

Glueful automatically creates REST APIs for your database tables. No code needed!

Create a Tasks Table

php glueful migrate:create CreateTasksTable

Edit the migration file:

<?php

namespace Glueful\Database\Migrations;

use Glueful\Database\Migrations\MigrationInterface;
use Glueful\Database\Schema\Interfaces\SchemaBuilderInterface;

class CreateTasksTable implements MigrationInterface
{
    public function up(SchemaBuilderInterface $schema): void
    {
        $schema->createTable('tasks', function ($table) {
            $table->bigInteger('id')->primary()->autoIncrement();
            $table->string('uuid', 12)->unique();
            $table->string('title', 255);
            $table->text('description')->nullable();
            $table->boolean('completed')->default(false);
            $table->timestamp('created_at')->default('CURRENT_TIMESTAMP');
            $table->timestamp('updated_at')->nullable();
        });
    }

    public function down(SchemaBuilderInterface $schema): void
    {
        $schema->dropTable('tasks');
    }
}

Run the migration:

php glueful migrate:run

Instant REST API

You now have a complete CRUD API automatically:

# List tasks
curl http://localhost:8000/tasks

# Create a task
curl -X POST http://localhost:8000/tasks \
  -H "Content-Type: application/json" \
  -d '{"title": "Learn Glueful", "description": "Build awesome APIs"}'

# Get single task
curl http://localhost:8000/tasks/{uuid}

# Update task
curl -X PUT http://localhost:8000/tasks/{uuid} \
  -H "Content-Type: application/json" \
  -d '{"completed": true}'

# Delete task
curl -X DELETE http://localhost:8000/tasks/{uuid}

All with:

  • ✅ Automatic pagination
  • ✅ Filtering and sorting
  • ✅ Validation
  • ✅ Error handling
  • ✅ UUID-based IDs

Next Steps

Ready to build? Start with the Essentials to learn routing, controllers, and database operations.