atlas-php v0.0.0
PHP version of the Atlas toolkit
A fast and easy way to write PHP programs with a graphical user interface (SPA like program).
With the Atlas toolkit, you obtain hybrid programs. Like desktop applications, the same code can handle both front and back ends, and, like web applications, the programs will be reachable from all over the internet.
Hello, World!
Here's how a Hello, World! type program made with the Atlas toolkit looks like:
git clone http://github.com/epeios-q37/atlas-php
cd atlas-php
php Hello/Hello.php
(with the pthreads extension)
For a live demonstration: http://q37.info/runkit/Hello.
Source code:
<?php
require "phar://Atlas.phar/Atlas.php";
class Hello extends Threaded {
static $body = <<<EOT
<div style="display: table; margin: 50px auto auto auto;">
<fieldset>
<input id="input" maxlength="20" placeholder="Enter a name here" type="text"
data-xdh-onevent="Submit" value="World"/>
<div style="display: flex; justify-content: space-around; margin: 5px auto auto auto;">
<button data-xdh-onevent="Submit">Submit</button>
<button data-xdh-onevent="Clear">Clear</button>
</div>
</fieldset>
</div>
EOT;
public function handle($dom, $action, $id) {
switch ($action) {
case "": // Action label for a new connection.
$dom->setLayout("", self::$body);
break;
case "Submit":
$dom->alert("Hello, " . $dom->getContent("input") . "!");
break;
case "Clear":
if ($dom->confirm("Are you sure?"))
$dom->setContent("input", "");
break;
}
$dom->focus("input");
}
}
function hello() {
return new Hello();
}
Atlas::launch('hello');
?>
TodoMVC
And here's how the Atlas toolkit version of the TodoMVC application looks like:
For a live demonstration: http://q37.info/runkit/TodoMVC.
Content of the repository
The Atlas
directory contains the PHP source code of the Atlas toolki, which is not needed to run the examples.
Atlas.phar
is the file which is needed to use the Atlas toolkit in your own program.
All other directories are examples.
To run an example, launch php <Name>/main.php
, where <Name>
is the name of the example (Blank
, Chatroom
…).
NOTA: You need PHP with pthreads!
The Atlas toolkit is also available for:
- Java: http://github.com/epeios-q37/atlas-java
- Node.js: http://github.com/epeios-q37/atlas-node
- Perl: http://github.com/epeios-q37/atlas-perl
- Python: http://github.com/epeios-q37/atlas-python
- Ruby: http://github.com/epeios-q37/atlas-ruby
For more information about the Atlas toolkit: http://atlastk.org/.
6 years ago