Getting started
Go from a fresh clone to a site on AWS Amplify: install, run it locally, add a page, and build.
Requirements
phossil runs PHP, nginx and Vite in Docker. You also need PHP and Node on your machine, for Composer and pnpm.
- Docker, with Compose
- PHP 8.5 with Composer
- Node 24 or later, with pnpm
Install
Clone the repository, then install the PHP autoloader and the Node tools.
git clone https://github.com/matthewaprice/phossil.git my-site
cd my-site
composer install # generates the class autoloader in vendor/
pnpm install # Vite, Tailwind, oxfmt and oxlint
Run it locally
Start the containers:
docker compose up --build
Open http://localhost:8000. Pages load their CSS
and JS from the Vite dev server on port 5173, so CSS and JS
changes appear without a reload, and saving a PHP file reloads
the page.
Add a page
-
Create
app/views/Pricing/Pricing.php, areadonlyclass that extendsApp\Components\View. -
Add a
RouteTypefor it toapp/routes/web.php. -
Optionally, add it to the navigation in
Layout::NAV.
A new page
<?php
namespace App\Views\Pricing;
use App\Components\Layout;
use App\Components\LayoutOptions;
use App\Components\View;
readonly class Pricing extends View
{
public function render(): string
{
return $this->capture(function () {
Layout::create(
new LayoutOptions(
content: $this->content(),
title: 'Pricing',
description: 'Plans for every size of team.'
)
);
});
}
private function content(): string
{
return $this->capture(function () {
?>
<h1 class="text-2xl font-bold">Pricing</h1>
<p>One plan, no surprises.</p>
<?php
});
}
}
<?php
use App\Services\Router\Route;
use App\Services\Router\RouteType;
use App\Views\Home\Home;
use App\Views\Pricing\Pricing;
Route::create(
new RouteType(path: '', view: Home::class),
new RouteType(path: 'pricing', view: Pricing::class),
);
It's served at /pricing/ straight away, and the
next build writes dist/pricing/index.html.
Build
With the containers still running, build the site and zip it:
composer build:zip
You get dist/, and dist.zip beside
it at the root of the repo:
404.html
index.html
features/index.html
getting-started/index.html
assets/app-[hash].css
assets/app-[hash].js
assets/img/
docker compose up --build first, on your
machine or in CI.
Deploy to AWS Amplify
To put the site, or a preview for a client, on AWS Amplify Hosting:
- In the Amplify console, create a new app and choose to deploy without a Git provider.
- Upload
dist.zip. - Once it's live, add your domain in the app's custom domain settings.
To serve the built 404 page, add a rewrite in the app's
rewrites and redirects settings, with source
/<*>, target /404.html and
type 404 (Rewrite).
Any other static host works the same way: upload what's in
dist/. To deploy on every push instead, run
composer build in a CI pipeline and publish
dist/.