Skip to content

dragonmantank/pamstack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pamstack

It's like JAMStack, but backed by PHP.

How to use

  1. Throw your static assets and front-end JS into source/. Your main webpage should be source/index.html
  2. 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"])
    ];
};
  1. 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());
  1. Run make deploy and visit http://localhost:8080

Functions

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.

Static Site Generation

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.

About

It's like JAMStack, but backed by PHP.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published