1. Go to this page and download the library: Download selikhovleonid/nadir 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/ */
namespace controllers;
use nadir\core\AbstractWebCtrl;
class Test extends AbstractWebCtrl
{
public function actionDefault()
{
// ...
$this->getView()->foo = 'foo';
$this->getView()->bar = array(42, 'bar');
$this->getView()->setVariables(array(
'baz' => 'baz',
'qux' => 'qux',
'quux' => 'quux',
));
// ...
$this->render();
}
}
namespace controllers;
use nadir\core\AbstractCliCtrl;
class Cli extends AbstractCliCtrl
{
public function actionTest(array $aArgs)
{
if (!empty($aArgs)) {
$this->printInfo('The test cli action was called with args: '
.implode(', ', $aArgs).'.');
} else {
$this->printError(new \Exception('The test cli action was called without args.'));
}
}
}
namespace controllers;
use nadir\core\AbstractWebCtrl;
class Test extends AbstractWebCtrl
{
public function actionDefault()
{
// ...
$this->setView('test', 'default');
$this->setLayout('main');
$this->getLayout()->isUserOnline = false;
$this->getView()->foo = 'foo';
$this->getView()->bar = array(42, 'bar');
// ...
$this->render();
}
}
namespace controllers;
use nadir\core\AbstractWebCtrl;
class Test extends AbstractWebCtrl
{
public function actionDefault()
{
// ...
$this->setView('test', 'default');
$this->setLayout('main');
$this->getView()->addSnippet('topbar');
$this->getView()
->getSnippet('topbar')
->isUserOnline = false;
$this->getView()->foo = 'foo';
$this->getView()->bar = array(42, 'bar');
// ...
$this->render();
}
}
namespace models;
use extensions\core\AbstractModel;
class Test extends AbstractModel
{
public function readDefault()
{
// Dummy mode
return array(
'foo' => 'bar',
'bar' => array(42, 'baz'),
);
}
}
namespace controllers;
use nadir\core\AbstractWebCtrl;
class Test extends AbstractWebCtrl
{
public function actionDefault()
{
$this->getView()->addSnippet('topbar');
$this->getView()
->getSnippet('topbar')
->isUserOnline = false;
$oModel = new \models\Test();
$aData = $oModel->readDefault();
$this->getView()->foo = $aData['foo'];
$this->getView()->bar = $aData['bar'];
$this->render();
}
}
namespace extensions\core;
use nadir\core\Request;
use nadir\core\AppHelper;
class Auth extends AbstractAuth
{
protected $request = null;
protected $routeConfig = null;
protected $error = null;
public function __construct(Request $oRequest)
{
$this->request = $oRequest;
$this->routeConfig = AppHelper::getInstance()->getRouteConfig();
}
protected function checkCookies(array $aCookies)
{
// Put your code here...
}
public function run()
{
if (!isset($this->routeConfig['auth'])) {
throw new \Exception("Undefined option 'auth' for the current route.");
}
$mCookies = $this->request->getAllCookies();
$this->checkCookies(!is_null($mCookies) ? $mCookies : array());
}
public function isValid()
{
return is_null($this->error);
}
public function onFail()
{
// Put your code here...
}
}