A PHP module written in Zephir that will allow you to run a version of BASIC language called kytschBASIC (aka KB) for the web.
- PHP 8.0 to 8.4
- PHP-GD
- PHP-MySQL (optional)
- PHP-Swoole (optional if want to run websockets for games and chat)
Now open your favourite terminal/console and clone the repo.
git clone https://github.com/kytschi/kytschBASIC.git
OR
git clone git@github.com:kytschi/kytschBASIC.gitEnable the kytschBASIC module. You can copy the sample ini file from the php folder in this repo. Remember to do this as root or
a user with administrator permissions.
cp kytschBASIC/php/kytschBASIC.ini /etc/php/8.4/mods-available/Edit the kytschBASIC.ini, then point the extension to the correct location and the desired php version, for example
extension=/var/www/kytschbasic/complied/php8.4-kytschbasic.so
And don't forget to restart the PHP service.
Next setup an index.php on your webserver of choice and tell it to load the kytschBASIC compiler.
<?php
(new KytschBASIC\Compiler(__DIR__ . '/../config'))->run();NOTICE we are loading in the configuration file. See configuration for more information on how to setup the configuration file.
For example website checkout the example folder in this repo.
It's worth blocking the compiled.php that gets created by KB in the root folder where you've installed KB to run from. Here's an example of how it can be done in Nginx.
location = /compiled.php {
return 444;
}
kytschBASIC configuration is handled via a JSON config file. From there you can define the database connection, the routes, etc. kytschBASIC example configs
The configuration for the database connection if needed. You can define more than one.
[
{
"name":"kytschBASIC", <-- Name of the connection
"type": "mysql", <-- Connection type
"host": "127.0.0.1", <-- Host IP
"port": 3306, <-- Host port
"dbname": "kytschBASIC", <-- Name of the database
"user": "user", <-- Username that has access
"password": "password" <-- Password of the user
}
]The routes allow you to define what kytschBASIC template is to be loaded for a specific URL or route.
[
{
"url": "/", <-- The URL/route that corresponds to the template.
"template": "project/index.kb" <-- The kytschBASIC template. Be sure to include its folder if its in one.
},
{
"url": "/about",
"template": "project/about.kb"
},
{
"url": "/installation",
"template": "project/installation.kb"
},
{
"url": "/news",
"template": "project/news.kb"
}
]First thing you will need is to install Zephir
Now to build the kytschBASIC PHP module run the following assuming kytschBASIC is the root folder for the source code.
cd kytschBASIC/kytschbasic
zephir buildTo start using the websocket server see the examples in example/websocket/server.php and example/websocket/js_client.kb.
You have to run the server for PHP cli with a command as follows,
cd kytschbasic/example/websocket
php -f server.php For more information and a to view the available command set please visit https://kytschbasic.org
The Arcade library makes use of JS-Cookie and jQuery.
Let me know via github.