From 96a007eecea9b67ba06d01c8fcdd9c09fc4b43e9 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 4 Nov 2025 23:31:01 -0800 Subject: Initial commit --- .github/PULL_REQUEST_TEMPLATE.md | 7 +++++++ .github/workflows/ci.yml | 20 ++++++++++++++++++ .gitignore | 14 +++++++++++++ LICENSE | 22 ++++++++++++++++++++ README.md | 41 +++++++++++++++++++++++++++++++++++++ build/Dockerfile | 13 ++++++++++++ composer.json | 43 +++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 11 ++++++++++ phel-config.php | 24 ++++++++++++++++++++++ public/css/style.css | 35 +++++++++++++++++++++++++++++++ public/images/favicon-32.png | Bin 0 -> 1254 bytes public/images/logo.svg | 5 +++++ public/index.php | 17 ++++++++++++++++ src/app.phel | 15 ++++++++++++++ src/controller/routes.phel | 13 ++++++++++++ src/module/greet.phel | 4 ++++ src/view/main.phel | 30 +++++++++++++++++++++++++++ tests/module/greet-test.phel | 6 ++++++ 18 files changed, 320 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 build/Dockerfile create mode 100644 composer.json create mode 100644 docker-compose.yml create mode 100644 phel-config.php create mode 100644 public/css/style.css create mode 100644 public/images/favicon-32.png create mode 100644 public/images/logo.svg create mode 100644 public/index.php create mode 100644 src/app.phel create mode 100644 src/controller/routes.phel create mode 100644 src/module/greet.phel create mode 100644 src/view/main.phel create mode 100644 tests/module/greet-test.phel diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..96a2bad --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,7 @@ +## 📚 Description + +Replace this text with a short description of your feature/bugfix. + +## 🔖 Changes + +- List individual changes in more detail diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..9d5feee --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,20 @@ +on: [push] + +name: CI + +jobs: + tests: + name: Tests + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.3 + coverage: none + - name: Install dependencies + run: composer update --no-interaction --no-ansi --no-progress + - name: Run phel tests + run: vendor/bin/phel test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0355937 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +.idea/ +.vscode/ +data/ +out/ +PhelGenerated/ +var/ +vendor/ + +!PhelGenerated/.gitkeep +*.cache +composer.lock +.phel-repl-history +phel-config-local.php +gacela*.php diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f3a7459 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2023 Jens Haase + Jose Maria Valera Reales + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..c2b43ae --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +# Phel Web Skeleton + +[Phel](https://phel-lang.org/) is a functional programming language that compiles to PHP. + +This repository provides you the basic setup to start coding a website using phel. + +## Getting started + +### Requirements + +Phel requires at least PHP 8.3 and Composer. + +#### Locally (no Docker) + +1. Ensure you have PHP >=8.3 (Some help about how to install multiple PHP versions locally on [linux](https://github.com/phpbrew/phpbrew) and [Mac](https://github.com/shivammathur/homebrew-php)) +1. Ensure you have [composer](https://getcomposer.org/composer-stable.phar) +1. Clone this repo +1. Install the dependencies | `composer install` + +#### Using Docker + +1. Clone this repo +1. Build the image | `docker-compose up -d --build` +1. Go inside the console | `docker exec -ti -u dev phel_web_skeleton bash` +1. Install the dependencies | `composer install` + +### Phel code + +1. Write your phel code in `src/` +2. Run your web server with + - `composer run:dev`: it will recompile the code on every request + - `composer run:prod`: it will run the same compiled code on every request + +### Tests + +1. Write your phel tests in `tests/` +1. Execute your tests with `composer test` + +## More about starting with phel + +Find more information about how to start with phel in [getting started](https://phel-lang.org/documentation/getting-started/). diff --git a/build/Dockerfile b/build/Dockerfile new file mode 100644 index 0000000..0fb5af1 --- /dev/null +++ b/build/Dockerfile @@ -0,0 +1,13 @@ +FROM php:8.3-fpm + +RUN apt-get update && \ + apt-get upgrade -y && \ + apt-get install -y git + +RUN pecl install -o -f xdebug \ + && rm -rf /tmp/pear \ + && docker-php-ext-enable xdebug + +COPY --from=composer /usr/bin/composer /usr/bin/composer +RUN useradd -m dev +WORKDIR /srv/phel-web-skeleton diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..27eccef --- /dev/null +++ b/composer.json @@ -0,0 +1,43 @@ +{ + "name": "phel-lang/web-skeleton", + "description": "A minimalistic skeleton to build your web-app using Phel Lang.", + "keywords": [ + "phel", + "lisp", + "functional", + "language" + ], + "homepage": "https://phel-lang.org/", + "license": "MIT", + "type": "project", + "require": { + "php": ">=8.3", + "phel-lang/phel-lang": ">=0.24", + "phel-lang/router": "^0.8" + }, + "require-dev": { + "symfony/var-dumper": "^6.4" + }, + "autoload": { + "psr-4": { + "PhelGenerated\\": "src/PhelGenerated" + } + }, + "scripts": { + "run:dev": [ + "Composer\\Config::disableProcessTimeout", + "rm -rf out && php -S localhost:8080 -t public" + ], + "run:prod": [ + "Composer\\Config::disableProcessTimeout", + "composer build && php -S localhost:8080 -t public" + ], + "build": "vendor/bin/phel build --no-cache", + "format": "vendor/bin/phel format", + "test": "vendor/bin/phel test", + "repl": [ + "Composer\\Config::disableProcessTimeout", + "vendor/bin/phel repl" + ] + } +} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..74089e8 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: "3.8" + +services: + phel_web_skeleton: + build: + context: . + dockerfile: build/Dockerfile + container_name: phel_web_skeleton + hostname: php + volumes: + - .:/srv/phel-web-skeleton:delegated diff --git a/phel-config.php b/phel-config.php new file mode 100644 index 0000000..779f65c --- /dev/null +++ b/phel-config.php @@ -0,0 +1,24 @@ +setSrcDirs(['src']) + ->setTestDirs(['tests']) + ->setVendorDir('vendor') + ->setKeepGeneratedTempFiles(false) + ->setFormatDirs(['src', 'tests']) + ->setBuildConfig((new PhelBuildConfig()) + ->setMainPhelNamespace('web-skeleton\app') + ->setMainPhpPath('out/index.php')) + ->setExportConfig((new PhelExportConfig()) + ->setFromDirectories(['src/phel']) + ->setNamespacePrefix('PhelGenerated') + ->setTargetDirectory('src/PhelGenerated')) + ->setIgnoreWhenBuilding(['local.phel']) + ->setNoCacheWhenBuilding(['web_skeleton/app']) +; diff --git a/public/css/style.css b/public/css/style.css new file mode 100644 index 0000000..edc12ff --- /dev/null +++ b/public/css/style.css @@ -0,0 +1,35 @@ +html, body { + font-family: "Helvetica", "Arial", sans-serif; + font-weight: 200; +} + +.full-height { + height: 80vh; +} + +.flex-center { + align-items: center; + display: flex; + justify-content: center; +} + +.position-ref { + position: relative; +} + +.content { + text-align: center; +} + +.links > a { + color: #35157f; + padding: 0 15px; + font-weight: bolder; + font-size: larger; + letter-spacing: .1rem; + text-decoration: none; +} + +.logo { + margin-bottom: 60px; +} \ No newline at end of file diff --git a/public/images/favicon-32.png b/public/images/favicon-32.png new file mode 100644 index 0000000..a24adc4 Binary files /dev/null and b/public/images/favicon-32.png differ diff --git a/public/images/logo.svg b/public/images/logo.svg new file mode 100644 index 0000000..25ba931 --- /dev/null +++ b/public/images/logo.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..92e0753 --- /dev/null +++ b/public/index.php @@ -0,0 +1,17 @@ +