minte9
LearnRemember



Laminas

MVC Skeleton Version: Laminas MVC 3.2 Create new laminas MVC project
 
cd /var/www/tests.local/php/laminas/

composer create-project -sdev laminas/laminas-mvc-skeleton myproject \
    --ignore-platform-reqs
 
http://tests.local/php/laminas/myproject/public/
    # Welcome page

http://tests.local/php/laminas/myproject/public/application/index
    # Welcome page
Add new action helloAction
 
// module/Application/src/Controller/IndexController.php
// ...

public function helloAction()
{
    $message = $this->params()->fromRoute('message');
    return new ViewModel(['message' => $message]);
}
Add new route hello-world
 
// module/Application/config/module.config.php
// ...

'hello-world' => [
    'type'    => Segment::class,
    'options' => [
        'route'    => '/hello[/:message]',
        'defaults' => [
            'controller' => Controller\IndexController::class,
            'action'     => 'hello',
            'message'    => 'World',
        ],
    ],
],
Add new view hello.phtml
 
// module/Application/view/application/index/hello.phtml

<div class="jumbotron">
    <p>
        Hello <?php echo $this->escapeHtml($message) ?>
    </p>
</div>
It works!
 
http://tests.local/php/laminas/myproject/public/hello
    # Hello World

http://tests.local/php/laminas/myproject/public/hello/Laminas
    # Hello Laminas



  Last update: 272 days ago