1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-11 13:55:55 +03:00
mal/impls/php
2021-12-11 09:52:02 -06:00
..
tests Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
core.php Change quasiquote algorithm 2020-08-11 01:01:56 +02:00
Dockerfile Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
env.php Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
interop.php Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
Makefile Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
printer.php Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
reader.php Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
readline.php Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
README.md Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
run Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
step0_repl.php Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
step1_read_print.php Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
step2_eval.php Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
step3_env.php Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
step4_if_fn_do.php Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
step5_tco.php Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
step6_file.php Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00
step7_quote.php Change quasiquote algorithm 2020-08-11 01:01:56 +02:00
step8_macros.php php: revent defmacro from mutating functions 2021-12-11 09:52:02 -06:00
step9_try.php php: revent defmacro from mutating functions 2021-12-11 09:52:02 -06:00
stepA_mal.php php: revent defmacro from mutating functions 2021-12-11 09:52:02 -06:00
types.php php: allow keyword argument for keyword core function 2021-12-11 09:52:02 -06:00
webrunner.php Move implementations into impls/ dir 2020-02-10 23:50:16 -06:00

Running .mal scripts on PHP hosting

Create a symlink to mal-web.php with the same name as your .mal script and your script will be executed as if it was PHP.

Here's an example using local dev.

First build mal-web.php:

cd mal/php
make mal-web.php

Now you can create a web runnable mal script:

echo '(println "Hello world!")' > myscript.mal
ln -s mal-web.php myscript.php

Start a development server with php -S 0.0.0.0:8000 and then browse to http://localhost:8000/myscript.php and you should see "Hello world!" in your browser as myscript.mal is run.

You can do the same thing on live PHP web hosting by copying mal.php up and creating a symlink for each .mal file you want to be web-executable.

PHP interop

In stepA_mal.mal you can find some examples of PHP interop.

Eval PHP code:

(php* "return 7;")
7

(php* "return array(7,8,9);")
(7 8 9)

Native function call:

(php/date "Y-m-d" 0)
"1970-01-01"

Accessing PHP "superglobal" variables:

(get php/_SERVER "PHP_SELF")
"./mal"