amsrafid/piper

Starter application for the Piper framework.

Maintainers

Package info

github.com/amsrafid/piper

Type:project

pkg:composer/amsrafid/piper

Transparency log

Statistics

Installs: 12

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-08-02 08:38 UTC

This package is not auto-updated.

Last update: 2026-08-17 07:19:26 UTC


README

This is the application you start from. It gives you the directory layout, the config files and the amsrafid console script, and it pulls in the framework as a dependency.

If you are looking for the framework itself, meaning routing, the container, middleware, migrations and the token guard, it lives in its own repository and its README is the one that documents them.

composer create-project amsrafid/piper my-api
cd my-api
cp env.example.xml env.xml
php amsrafid migrate

Then point a web server at public/. On Apache, public/.htaccess already handles the rewrite.

Set your app key before anything else

env.xml ships with an empty <key>. The framework refuses a request without one of at least 60 characters. That is deliberate, because a token signed with a guessable key is worse than no token at all.

php -r "echo bin2hex(random_bytes(32));"

Paste the result into <app><key> in env.xml, and fill in the database block below it while you are there. env.xml is git-ignored. env.example.xml is the copy that gets committed, so keep secrets out of it.

<debug> ships as false. Turn it on while you are building, since it is what puts the stack trace in the response, and turn it back off before anything is reachable from outside.

What is in here

app/
  Console/Kernel.php          your console commands
  Exceptions/                 your exception dispatcher
  Http/
    Controllers/              routes live here, by convention or by attribute
    Middleware/
    Kernel.php                global, prefix and route middleware
  Models/
config/                       app, auth, database, path, request, storage
database/
  migrations/                 make:migration writes here
  migrates.json               what has been migrated
public/index.php              the entry point
storage/
amsrafid                      the console script

Your first route

Write a method. That is the whole step, the convention routes it:

namespace App\Http\Controllers;

class ShopController extends Controller
{
    public function index()
    {
        return $this->response(['items' => []]);   // GET /shop/index
    }
}

When the convention is not enough, say for a slug, a version prefix or a specific verb, declare it:

use Piper\Routing\Attributes\Get;

#[Get('/shop/{slug}')]
public function bySlug($slug)
{
    return $this->response(['slug' => $slug]);
}

Both styles work in the same controller. The framework README covers the rest of the attributes, along with middleware, migrations and the token guard.

Console

php amsrafid make:controller Shop
php amsrafid make:model Order
php amsrafid make:migration create_orders_table
php amsrafid migrate
php amsrafid migration:status
php amsrafid storage:link

Requirements

PHP 8.0 to 8.3.

Author

A. M. Sadman Rafid, amsrafid.com ยท github.com/amsrafid

Security

If you find a security problem, please email amsrafid@gmail.com rather than opening a public issue.

License

MIT.