It's like JAMStack, but backed by PHP.
- Throw your static assets and front-end JS into
source/
. Your main webpage should besource/index.html
- Throw a function into a file inside
functions/
. As an example:
<?php
# functions/hello-world.php
return function() {
return [
'status' => 200,
'body' => json_encode(['message' => "Hello World"])
];
};
- Scripts will be mapped to
/.pamstack/functions/[file-name]
, so the above becomes/.pamstack/functions/hello-world
const data = await fetch('/.pamstack/functions/hello-world').then(response => response.json());
- Run
make deploy
and visithttp://localhost:8080
Each function script should return a function or invokable object that returns JSON. The structure of the JSON
should return a status
key with the HTTP status code to return, and a body
key with the JSON body that will
be returned.
The routing script will translate that into the proper HTTP status code return and JSON body for your front-end to consume.
PAMStack includes Sculpin as a static site generator. You can put your Sculpin source files into the source/
directory and Sculpin will build the static portion of your site in the background automatically. Functions included in the functions/
folder will continue to be invoked dynamically.