Did you find something wrong? Be sure to let us know with an issue. Thank you!
One Project
The One template is Webisters' single-file project. Every endpoint lives in one PHP file — perfect for quick APIs, prototypes, internal tools, or anything you want to deploy in under a minute. Same libraries as the App and API templates, none of the directory ceremony.
- When to use One
- Installation
- Project layout
- Defining endpoints
- Running the app
- Growing out of One
- Conclusion
When to use One
- A throwaway internal tool with three endpoints.
- A webhook receiver that just needs to validate a signature and forward.
- A prototype where you want to iterate on logic without thinking about file structure.
- A small JSON API exposed to a single client.
When the file grows past a few hundred lines or you need fixtures, migrations, and views, move to the App or API template.
Installation
Create a project with Composer:
composer create-project webisters/one my-app
cd my-app
Or via the Webisters CLI:
webisters new-one my-app
cd my-app
composer install
Project layout
my-app/
├── composer.json
├── preload.php
├── public/
│ └── index.php <-- everything lives here
└── storage/
That's it. public/index.php is your entire application.
Defining endpoints
Open public/index.php and register handlers directly:
<?php
require __DIR__ . '/../vendor/autoload.php';
use Framework\Routing\Router;
use Framework\HTTP\Response;
$router = new Router();
$router->get('/', fn () => new Response()->setBody('Hello, world!'));
$router->get('/users/{id:int}', function (int $id) {
return new Response()->setJSON([
'id' => $id,
'name' => 'User ' . $id,
]);
});
$router->post('/contact', function () {
$data = json_decode(file_get_contents('php://input'), true) ?? [];
// ... validate, send email, log, etc.
return new Response()->setStatus(201);
});
$router->match($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI'])->run();
Running the app
Use PHP's built-in server for local development:
php -S localhost:8000 -t public
For production, point your web server (nginx, Caddy, Apache) at the public/ directory.
Growing out of One
When you start splitting your handlers into classes or adding views, migrations, and seeders, scaffold an App project alongside and copy your routes across. Both templates share the same library set, so the move is mostly cut-and-paste plus a routes file.
Conclusion
One is the fastest path from idea to running PHP service. Don't be afraid to start here — you can always graduate to a richer template when the constraints start hurting.