1
1
mirror of https://github.com/kanaka/mal.git synced 2024-11-11 00:52:44 +03:00
mal/php/README.md

43 lines
1.0 KiB
Markdown
Raw Normal View History

### Running .mal scripts on PHP hosting ###
2018-06-24 14:45:29 +03:00
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.
2018-06-24 14:45:29 +03:00
Here's an example using local dev.
2018-06-24 14:45:29 +03:00
First build `mal-web.php`:
2018-06-24 14:45:29 +03:00
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.
2016-10-29 07:32:26 +03:00
### PHP interop ###
In [stepA_mal.mal](./tests/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:
2018-06-24 11:31:40 +03:00
(php/date "Y-m-d" 0)
"1970-01-01"
2016-10-29 07:32:26 +03:00
Accessing PHP "superglobal" variables:
2018-06-24 11:31:40 +03:00
(get php/_SERVER "PHP_SELF")
"./mal"
2016-10-29 07:32:26 +03:00