1. Go to this page and download the library: Download anax/controller library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
anax / controller example snippets
/**
* Display the stylechooser with details on current selected style.
*
* @return object
*/
public function indexAction() : object
{
$title = "Stylechooser";
$page = $this->app->page;
$session = $this->app->session;
$page->add("anax/v2/stylechooser/default", [
"activeStyle" => $session->get("active-style", null),
]);
return $page->render([
"title" => $title,
]);
}
/**
* Call the controller index action.
*/
public function testIndexAction()
{
// Create and initiate the controller
$this->controller = new SampleAppController();
$this->controller->setApp($app);
$this->controller->initialize();
// Carry out the test
$res = $this->controller->indexAction();
$this->assertIsString($res);
$this->assertStringEndsWith("active", $res);
}
/**
* Setup the controller, before each testcase, just like the router
* would set it up.
*/
protected function setUp(): void
{
// Init service container $di to contain $app as a service
$di = new DIMagic();
$app = $di;
$di->set("app", $app);
// Create and initiate the controller
$this->controller = new SampleAppController();
$this->controller->setApp($app);
$this->controller->initialize();
}
/**
* Call the controller index action.
*/
public function testIndexAction()
{
$res = $this->controller->indexAction();
$this->assertIsString($res);
$this->assertStringEndsWith("active", $res);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.