PAM HTTP Starter
pushinbr/pam-skeleton is a ready-to-run API built with PAM HTTP. It shows the structure the
package recommends, end to end: a thin controller, a form request that hydrates a DTO, a service, a repository
backed by the Arcano ORM, a JSON resource, an explicit migration and an in-memory test.
Creating a Project
Section titled “Creating a Project”Install PAM, then create the project with PAM’s Composer:
pam composer create-project pushinbr/pam-skeleton my-apicd my-apiPrepare a SQLite database and run the migrations:
mkdir -p storage && touch storage/database.sqliteexport DB_CONNECTION=sqlite DB_DATABASE=$PWD/storage/database.sqlitepam composer migrateStart the development server:
pam dev index.phpThe API listens on http://127.0.0.1:3000; set PAM_PORT to change it. Try it:
curl http://127.0.0.1:3000/api/ping# {"data":{"status":1,"message":"pong","requestId":null}}
curl -X POST http://127.0.0.1:3000/api/products \ -H 'content-type: application/json' \ -d '{"name":"Mechanical keyboard","priceInCents":34990}'# 201 {"data":{"id":1,"name":"Mechanical keyboard","priceInCents":34990,"status":1}}
curl http://127.0.0.1:3000/api/products# {"data":[{"id":1,"name":"Mechanical keyboard","priceInCents":34990,"status":1}]}An invalid payload returns 422 Problem Details with the error for each field.
Directory Structure
Section titled “Directory Structure”my-api/├── index.php # configuration, providers, middleware, routes, listen()├── bin/migrate # migration runner (pam composer migrate)├── database/migrations/ # Arcano migrations├── src/│ ├── Domain/Products/ # CreateProductData DTO, ProductStatus enum│ ├── Http/Controllers/ # PingController, ProductController│ ├── Http/Requests/ # StoreProductRequest│ ├── Http/Resources/ # PingResource, ProductResource│ ├── Models/Product.php # #[Entity] mapped by Arcano│ ├── Providers/AppServiceProvider.php│ ├── Repositories/ # ProductRepository + ArcanoProductRepository│ └── Services/ # ProductService, ReadinessService├── tests/ApplicationTest.php # in-memory tests└── .env.exampleHow a Request Flows
Section titled “How a Request Flows”POST /api/products passes through each layer:
index.phpmaps the route to[ProductController::class, 'store'].StoreProductRequestvalidatesnameandpriceInCentsand exposesdata(), which hydrates the readonlyCreateProductDataDTO.ProductControllerstays thin: it callsProductService::create().ProductServiceowns the use case and talks to theProductRepositoryinterface.AppServiceProviderbindsProductRepositorytoArcanoProductRepository, which persists theProductentity.ProductResourceturns the entity into JSON and the controller returns it with status201.
Statuses are integer-backed enums (ProductStatus::Active = 1, Archived = 2), so the API exposes stable numbers.
Configuration
Section titled “Configuration”index.php validates configuration at boot with
Configuration and installs SecurityHeadersMiddleware.
.env.example lists the variables:
PAM_PORT=3000PAM_WORKERS=4DB_CONNECTION=sqliteDB_DATABASE=storage/database.sqliteAny database variable supported by DatabaseConfig::fromEnvironment()
works. PostgreSQL is the default when DB_CONNECTION is not set.
Database and Migrations
Section titled “Database and Migrations”Entities in src/Models are compiled into var/cache/arcano-schema.php. The cache is rebuilt when an entity
changes, except when PAM_ENV=production.
Migrations never run while workers boot, so concurrent workers cannot race schema changes. Use the Composer script:
pam composer migrate # run pending migrationspam composer migrate generate # write a migration for changed entitiespam composer migrate rollback 1 # revert the last migrationpam composer migrate status # list migrations and when they ranpam composer migrate cache # rebuild the schema cache (deployments)Running migrate again is safe; it reports that the database is already up to date.
Testing
Section titled “Testing”pam composer testThe script runs PHPUnit inside PAM (pam test --phpunit -c phpunit.xml). tests/ApplicationTest.php checks the
ping endpoint and the full product flow against a temporary SQLite database, including a 422 response. See
HTTP Testing.
Deployment
Section titled “Deployment”- Build the schema cache with
pam composer migrate cacheand runpam composer migrateas a release step. - Set
PAM_ENV=productionso the schema is never rescanned at runtime. - Run the application with
pam start index.phpand configure listener limits, trusted proxies and TLS termination. See Production. - Run
pam doctorafter dependency changes.
Versions
Section titled “Versions”| Skeleton | PAM HTTP | ORM |
|---|---|---|
| 2.1.0 | ^2.2 |
Arcano (pushinbr/arcano) |
| 2.0.x | ^2.0 |
Eloquent |
The skeleton requires PHP 8.5, pushinbr/pam-http, pushinbr/pam-http-psr, pushinbr/pam-socket and
pushinbr/arcano, with pushinbr/pam-http-testing, PHPUnit and Laravel Pint for development. Files you copy from
the skeleton are yours to use under any terms; the skeleton itself is licensed under the Apache License 2.0.