composer require piano/mvc
composer create-project piano/mvc project-name dev-project
$this->redirect('/module/controller/action');
$this->redirect(
'/module/controller/action',
[
'firstName' => 'Diogo',
'lastName' => 'Cavilha',
]
);
$id = $this->getParam('id');
$params = $this->getParams();
If you need to create a constructor method for your controller, you can do this by creating a method called initialize()
instead of __construct()
.
The __construct()
method is already being used by Piano\Mvc\Controller
.
<?php
namespace app\modules\application\controllers;
class IndexController extends Piano\Mvc\Controller
{
protected function initialize()
{
// Do some action before executing any other code of your controller.
}
}
$this->view->render('view-name');
$this->view->render('view-name', ['name' => 'Diogo']);
$this->view->disableLayout(); // disabling
$this->view->disableLayout(true); // disabling
$this->view->disableLayout(false); // enabling
$this->partial('/path/to/file');
$this->partial('/path/to/file', ['title' => '']);
<a href="<?php echo $this->url('route_name'); ?>">Text</a>
<form action="<?php echo $this->url('contact'); ?>" method="post">
Name: <input type="text" name="name">
Email: <input type="text" name="email">
<input type="submit" name="Send">
</form>
$this->getApplication()->getModuleName();
$this->getApplication()->getControllerName();
$this->getApplication()->getActionName();