michaelyousrie/batframe-skeleton

A skeleton to bootstrap a new Batframe application with `composer create-project`.

Maintainers

Package info

github.com/michaelyousrie/batframe-skeleton

Type:project

pkg:composer/michaelyousrie/batframe-skeleton

Transparency log

Statistics

Installs: 25

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.2.0 2026-07-17 03:31 UTC

This package is auto-updated.

Last update: 2026-07-17 03:33:19 UTC


README

A starting point for a new Batframe application. It gives you the same layout as the framework's example app, ready to run.

Create a project

composer create-project michaelyousrie/batframe-skeleton my-app
cd my-app
php batbelt serve

Then open http://localhost:1939. composer create-project installs the dependencies and copies .env.example to .env for you.

Layout

batbelt              # your project's CLI (see below)
public/index.php     # front controller (document root)
src/App.php          # your app class, extends Batframe
src/Routes/          # route traits, grouped by feature
views/               # Blade templates
pages/               # auto-routed static pages
storage/cache/       # compiled Blade cache (writable)
.env                 # environment (copied from .env.example)

Add a route

Every verb-prefixed public method becomes an endpoint, with the route inferred from the method name. Put them on your App class, or group them into a trait under src/Routes/ and use it, the way PageRoutes already is.

php batbelt makeRoute Product creates the trait and wires it in for you:

// src/Routes/ProductRoutes.php
public function getProducts(): array        // GET /products
{
    return ['products' => []];
}

public function getProduct(int $id): array  // GET /product/{id}
{
    return ['id' => $id];
}

php batbelt routes shows you everything the app answers, pages included.

See the Batframe documentation for the full routing convention, request and response helpers, views, and config.

Batbelt

batbelt is your project's command line tool. It is a single file with no dependencies, and it is yours: open it and edit it.

php batbelt                      # list every command
php batbelt <command> --help     # what a command takes

php batbelt serve                # http://localhost:1939 (alias: server)
php batbelt serve --port=4000    # somewhere else
php batbelt routes               # every route your app resolves
php batbelt makeRoute Product    # scaffold src/Routes/ProductRoutes.php and wire it in
php batbelt makePage pricing     # scaffold pages/pricing.blade.php, live at /pricing
php batbelt clearCache           # empty storage/cache

composer serve still works and runs php batbelt serve.

Add a command

Batbelt works the way Batframe works. Batframe turns the public methods of your App class into routes; Batbelt turns the public methods of its Batbelt class into commands. So a new command is a new public method, named exactly as you want to type it:

// batbelt
final class Batbelt extends Belt
{
    /**
     * Say hello.
     *
     * @param string $name  Who to greet.
     * @param bool   $shout Use your outside voice.
     */
    public function greet(string $name, bool $shout = false): int
    {
        $this->line($shout ? strtoupper("hi $name") : "hi $name");

        return 0;
    }
}
php batbelt greet Ada --shout

That is the whole thing. The parameters became arguments: one without a default is positional, one with a default becomes an optional --flag starting from that default, and the declared type does the casting, so --port=abc on an int is a clean error instead of a crash. The docblock became the help text. Private methods are helpers rather than commands, which is where --help and the exit code came from without you writing either.