1. Go to this page and download the library: Download aura/web-project 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/ */
aura / web-project example snippets
namespace Aura\Web_Project\_Config;
use Aura\Di\Config;
use Aura\Di\Container;
class Common extends Config
{
// ...
public function modifyWebRouter(Container $di)
{
$request = $di->get('aura/web-kernel:request');
$response = $di->get('aura/web-kernel:response');
$router = $di->get('aura/web-kernel:router');
$router
->add('blog.read', '/blog/read/{id}')
->addValues(array(
'action' => function ($id) use ($request, $response) {
$content = "Reading blog post $id";
$response->content->set(htmlspecialchars(
$content, ENT_QUOTES|ENT_SUBSTITUTE, 'UTF-8'
));
}
));
}
// ...
}
namespace Aura\Web_Project\_Config;
use Aura\Di\Config;
use Aura\Di\Container;
class Common extends Config
{
// ...
public function modifyWebRouter(Container $di)
{
$router = $di->get('aura/web-kernel:router');
$router
->add('blog.read', '/blog/read/{id}')
->addValues(array(
'action' => 'blog.read',
));
}
public function modifyWebDispatcher(Container $di)
{
$request = $di->get('aura/web-kernel:request');
$response = $di->get('aura/web-kernel:response');
$dispatcher = $di->get('aura/web-kernel:dispatcher');
$dispatcher->setObject(
'blog.read',
function ($id) use ($request, $response) {
$content = "Reading blog post $id";
$response->content->set(htmlspecialchars(
$content, ENT_QUOTES|ENT_SUBSTITUTE, 'UTF-8'
));
}
);
}
// ...
}
/**
* {$PROJECT_PATH}/src/App/Actions/BlogReadAction.php
*/
namespace App\Actions;
use Aura\Web\Request;
use Aura\Web\Response;
class BlogReadAction
{
public function __construct(Request $request, Response $response)
{
$this->request = $request;
$this->response = $response;
}
public function __invoke($id)
{
$content = "Reading blog post $id";
$this->response->content->set(htmlspecialchars(
$content, ENT_QUOTES|ENT_SUBSTITUTE, 'UTF-8'
));
}
}
namespace Aura\Web_Project\_Config;
use Aura\Di\Config;
use Aura\Di\Container;
class Common extends Config
{
public function define(Container $di)
{
$di->set('aura/project-kernel:logger', $di->lazyNew('Monolog\Logger'));
$di->params['App\Actions\BlogReadAction'] = array(
'request' => $di->lazyGet('aura/web-kernel:request'),
'response' => $di->lazyGet('aura/web-kernel:response'),
);
}
// ...
}
namespace Aura\Web_Project\_Config;
use Aura\Di\Config;
use Aura\Di\Container;
class Common extends Config
{
// ...
public function modifyWebDispatcher(Container $di)
{
$dispatcher = $di->get('aura/web-kernel:dispatcher');
$dispatcher->setObject(
'blog.read',
$di->lazyNew('App\Actions\BlogReadAction')
);
}
// ...
}
namespace Aura\Web_Project\_Config;
use Aura\Di\Config;
use Aura\Di\Container;
class Common extends Config
{
// ...
public function modifyWebRouter(Container $di)
{
$router = $di->get('aura/web-kernel:router');
$router->add('blog.read', '/blog/read/{id}');
}
// ...
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.