Lisp like its Javacript+PHP (yes, needs PHP installed)
Examples for programming small reactive web-apps in Lisp. Back- and frontend use Clojure inspired Lisp interpreters: Phel and Scittle. Because the interpreters run on PHP and Javascript respectively, the code can be deployed on cheap shared web-hosting.
There are two examples, both canonical: Guestbook and Todo-MVC. They show how to administer the interplay between frontend and backend the Clojure way. While Guestbook (taken directly from the Luminus book) is simpler and has a more traditional REST api, Todo-MVC has an advanced GraphQL api via Qlkit
You need to install PHP 7.4 (or later) and download the file composer.phar into the directory of the cloned repository. Then, download Phel with:
php composer.phar install
delete the /out
directory and compile the project with
rm ./out
./vendor/bin/phel compile
Start a server with:
php -S localhost:8000
if you want to do development without the compilation step, you need to uncomment the first five lines in index.php
and delete the rest of the lines.
To try the Guestbook example, type in the adress bar of your browser:
http://localhost:8000/?guestbook
The Phel and Scittle code are in the files phel/guestbook.phel
and cljs/guestbook.cljs
, both sport the Clojure(Script) syntax and the goodness of persistent data structures.
You need to have the MySql database installed. You also need to replace the connection string in the file mysqldsn.txt
. Then, start with
http://localhost:8000/
The code in little-clojure/honey-sql.phel
implements a very small subset of HoneySQL which translates Clojure/Phel datastructures (like {:select [:id] :from [:todos]}
) into SQL strings.
The code in little-clojure/core.phel
contains a crude imitation of Clojure multimethods, which are necessary for implementing Qlkit's parsers.
I needed to expose Qlkit to Scittle (see branch clj-ajax-plugin
, scittle/src/scittle/qlkit.cljs
). All of this Clojurescript code is compiled into publicly served Javascript files, but can be self-compiled following the Scittle instructions.
Moreover, the 60 loc server part of Qlkit had to be ported to Phel.
./vendor/bin/phel test
./vendor/bin/phel format phel
./vendor/bin/phel format tests