File: routes/web.php
$r->get('/', ['HomeController@index']);
$r->post(
'/',
[
'PostController@store',
'middlewares' => ['CsrfVerify']
]
);
File: src/Controllers/HomeController.php
<?php declare (strict_types=1);
namespace App\Controllers;
use App\View\FrontRenderInterface;
use App\Util\AppSession;
class HomeController
{
private $view;
private $session;
public function __construct(
FrontRenderInterface $view,
AppSession $session
)
{
$this->view = $view;
$this->session = $session;
$this->session->sessStart();
}
}
public function index(array $param = [])
{
return $this->view->render('[view_name]', [
'data' => ModelData::all()
]);
}
File: resources/views/home.php
<?php $this->layout('layout', ['title' => 'Home Page']);?>
<ul>
<?php foreach($data as $row): ?>
<li><?=$this->e($row->name)?></li>
<form action='' method='post'>
<?=$this->_method('put')?>
<?=$this->csrf()?>
<input type='text' name='name'/>
<input type='submit' value='submit' />
</form>
<?php endforeach; ?>
</ul>
- tsc
compile typescripts files to public/js/
- composer asset
compile app.scss to public/app.css
- composer test
run phpunit tests
- composer test-log
create phpunit log
- composer test-coverage
create phpunit coverage