Amonite is a web client-side (JS) and server-side (PHP and NodeJS) engine. It is an engine that complies with HTTP standards, lightweight, easy to use. It's an engine that lets you decide how the program should go forward.
Amonite is a good PHP engine :
- with NoSQL or PDO,
- with torque Request / Controller,
- with Document / Component couple and
- with Throwable / Answerable response easy to use.
- Easy paradigm,
- Soft framework,
- Easy installation,
- 3 Steps document sending and
- Follow HTTP Standards.
- You need heavy control system,
- You don't trust your teammates and
- Expensive tools are most qualitative.
Entire Amonite engine is archived as a PHAR file. Put it on root, or any where : /amonite.phar
May be you would like use it with default config. Then just call it like :
<?php
// Get library
require_once __DIR__ . "/amonite.phar";
// Set file root
Amonite\Response::i()->env->theme = __DIR__ . "/theme/main";
// Execute anonymous function then send response
Amonite\Response::send(Amonite\Controller::auto());
Amonite default config uses Throwable, Answerable, Request, Response and CustomException. These classes helps you to produce better system in CraftmanShip approach. Amonite\Response::send($value)
can send scalar values (integer, float, string or boolean) or array or any Answerable
child class (CustomException
, Content
, Document
, Component
, File
or DownloadFile
Amonite classes available by default).
You can enhance the engine with Document / Component model or you can create any class that extends Content
class or implements Answerable
interface. In example :
File : /templates/documents/IndexDocument.php
<?php
require_once ROOT . "/templates/components/NavComponent.php";
namespace App;
class IndexDocument extends Amonite\Document {
function getDocument( Amonite\Request $req, Amonite\Response $res ) {
?>
<!doctype html>
<html>
<head>
</head>
<body>
<?php echo ( new NavComponent() )->getContent(); ?>
</body>
</html><?php
}
}
File : /templates/components/NavComponent.php
<?php
namespace App;
class NavComponent extends Amonite\Component {
// called only if an argument key (into $argv, $_FILES, $_GET, $_POST) is "Nav"
function onCall( Request $req, Response $res ) {
throw new HttpCode( 403 ); // Forbidden access
}
// function called by $this->getContent()
function getComponent( Amonite\Request $req, Amonite\Response $res ) {
?>
<nav>
<ul>
<li>
<a href="#a">A</a>
</li>
<li>
<a href="#b">B</a>
</li>
<li>
<a href="#c">C</a>
</li>
</ul>
</nav>
<?php
}
}
File : /theme/main/index.html.php
<?php
namespace App;
return new IndexDocument;
You can enhance the engine with ModelBSON / ModelPDO model or you can create any class that implements Model
interface. Use one of these Model, then In example :
<?php
namespace Amonite;
interface Model {
public function __construct( $name = "" );
public function select( $fields = array(), $where = array(), $limit = 0, $start_at = 0 ); // return array of items
public function selectFirst( $fields = array(), $where = array(), $start_at = 0 ); // return first items
public function count( $where = array(), $limit = 0, $start_at = 0 ); // return integer count
public function remove( $where = array(), $limit = 0, $start_at = 0 ); // return array of items
public function update( $value = array(), $where = array(), $limit = 0, $start_at = 0 ); // return array of items items
public function insert( $value = array() ); // return item
}