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.

Terminal
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:

Terminal
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

  1. Create app/views/Pricing/Pricing.php, a readonly class that extends App\Components\View.
  2. Add a RouteType for it to app/routes/web.php.
  3. 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
        });
    }
}

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:

Terminal
composer build:zip

You get dist/, and dist.zip beside it at the root of the repo:

dist/
404.html
index.html
features/index.html
getting-started/index.html
assets/app-[hash].css
assets/app-[hash].js
assets/img/
The build renders each page through the running nginx and PHP containers, so start them with 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:

  1. In the Amplify console, create a new app and choose to deploy without a Git provider.
  2. Upload dist.zip.
  3. 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/.