SlideShare a Scribd company logo
Routing in Zend Framework 3
• Creati controllerele
WelcomeController si HomeController
WelcomeController
<?php
namespace TestController;
use ZendMvcControllerAbstractActionController;
use ZendViewModelViewModel;
class WelcomeController extends AbstractActionController
{
public function indexAction()
{
$viewModel = new ViewModel();
$viewModel->setTemplate('test/welcome/index');
return $viewModel;
}
}
Module/Test/config/module.config.php
………………………………….
return [
'router' => [
'routes' => [
'home' => [
'type' => Literal::class,
'options' => [
'route' => '/',
'defaults' => [
'controller' => ControllerIndexController::class,
'action' => 'index',
],
],
],
///////////////////////////////////////////////
'welcome' => [
'type' => Literal::class,
'options' => [
'route' => '/welcome',
'defaults' => [
'controller' => ControllerWelcomeController::class,
'action' => 'index',
],
],
],
///////////////////////////////
…………………………………………………………………………………………….
…………………………………….
'controllers' => [
'factories' => [
ControllerIndexController::class => InvokableFactory::class,
ControllerWelcomeController::class => InvokableFactory::class,
],
],
…………………………….
…………………………………….
'view_manager' => [
'display_not_found_reason' => true,
'display_exceptions' => true,
'doctype' => 'HTML5',
'not_found_template' => 'error/404',
'exception_template' => 'error/index',
'template_map' => [
'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
'test/index/index' => __DIR__ . '/../view/test/index/index.phtml',
'test/welcome/index' => __DIR__ .
'/../view/test/welcome/index.phtml',
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index' => __DIR__ . '/../view/error/index.phtml',
],
…………………………….
• Creati directorul
/module/Test/view/test/welcome
si in acesta fisierul index.html in care scrieti:
<h1>Welcome!</h1>
<br/><br/>
<a href="../">Back</a>
http://localhost:8080/welcome
WelcomeController
…………………
public function contactAction()
{
$viewModel = new ViewModel();
$viewModel->setTemplate('test/welcome/contact');
return $viewModel;
}
Module/Test/config/module.config.php
///////////////////////////////////////////////
‘contact' => [
'type' => Literal::class,
'options' => [
'route' => '/contact',
'defaults' => [
'controller' => ControllerWelcomeController::class,
'action' => 'contact',
],
],
],
///////////////////////////////
……………………………….
'view_manager' => [
'display_not_found_reason' => true,
'display_exceptions' => true,
'doctype' => 'HTML5',
'not_found_template' => 'error/404',
'exception_template' => 'error/index',
'template_map' => [
'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
'test/index/index' => __DIR__ . '/../view/test/index/index.phtml',
'test/welcome/index' => __DIR__ . '/../view/test/welcome/index.phtml',
'test/welcome/contact' => __DIR__ .
'/../view/test/welcome/contact.phtml',
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index' => __DIR__ . '/../view/error/index.phtml',
],
• Creati fisierul index.html in directorul:
/module/Test/view/test/welcome
si in acesta in care scrieti:
<h1>This is contact page!</h1>
<br/><br/>
<a href="../">Back</a>
http://localhost:8080/contact
In fisierul index.html din directorul:
/module/Test/view/test/index
scrieti:
<h1 style="text-align: center;"><font color="red">URA!!!</font></h1>
<br/><br/>
<a href="welcome">Welcome page</a>
<br/><br/>
<a href="contact">Contact page</a>

More Related Content

PDF
Codeigniter : Custom Routing - Manipulate Uri
PDF
There's a Filter For That
PDF
Django Vs Rails
KEY
Django Admin: Widgetry & Witchery
PPTX
DJango admin interface
PPTX
Java script functions
PPTX
Ch2(working with forms)
PPTX
AngularJS Routing
Codeigniter : Custom Routing - Manipulate Uri
There's a Filter For That
Django Vs Rails
Django Admin: Widgetry & Witchery
DJango admin interface
Java script functions
Ch2(working with forms)
AngularJS Routing

What's hot (20)

PPTX
Template syntax in Angular 2.0
PDF
How to create a magento controller in magento extension
PPTX
AngularJS Compile Process
PDF
How to Create A Magento Adminhtml Controller in Magento Extension
KEY
Keeping It Simple
PDF
Customizing the Django Admin
PPTX
AngulrJS Overview
PDF
Angular JS Routing
PDF
ActiveResource & REST
PDF
Angular Promises and Advanced Routing
PPTX
Angular 1.x vs. Angular 2.x
PDF
WordPress Capabilities Magic
PPTX
Sins Against Drupal 2
PPTX
Drupal sins 2016 10-06
PPTX
Dive into AngularJS Routing
PPT
Presentation
PDF
PPTX
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
TXT
Sql procedures
PDF
Angular JS blog tutorial
Template syntax in Angular 2.0
How to create a magento controller in magento extension
AngularJS Compile Process
How to Create A Magento Adminhtml Controller in Magento Extension
Keeping It Simple
Customizing the Django Admin
AngulrJS Overview
Angular JS Routing
ActiveResource & REST
Angular Promises and Advanced Routing
Angular 1.x vs. Angular 2.x
WordPress Capabilities Magic
Sins Against Drupal 2
Drupal sins 2016 10-06
Dive into AngularJS Routing
Presentation
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
Sql procedures
Angular JS blog tutorial
Ad

More from Razvan Raducanu, PhD (20)

PPTX
12. edit record
PPTX
11. delete record
PPTX
10. view one record
PPTX
9. add new record
PPTX
8. vederea inregistrarilor
PPTX
PPTX
6. hello popescu 2
PPTX
5. hello popescu
PPTX
4. forme in zend framework 3
PPTX
3. trimiterea datelor la vederi
PPTX
1. zend framework intro
PPTX
18. images in symfony 4
PPTX
17. delete data
PPTX
16. edit data
PPTX
15. view single data
PPTX
14. add data in symfony4
PPTX
13. view data
PPTX
12.doctrine view data
PPTX
11. move in Symfony 4
PPTX
10. add in Symfony 4
12. edit record
11. delete record
10. view one record
9. add new record
8. vederea inregistrarilor
6. hello popescu 2
5. hello popescu
4. forme in zend framework 3
3. trimiterea datelor la vederi
1. zend framework intro
18. images in symfony 4
17. delete data
16. edit data
15. view single data
14. add data in symfony4
13. view data
12.doctrine view data
11. move in Symfony 4
10. add in Symfony 4
Ad

Recently uploaded (20)

PPTX
Institutional Correction lecture only . . .
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Cell Structure & Organelles in detailed.
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Computing-Curriculum for Schools in Ghana
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
Cell Types and Its function , kingdom of life
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Classroom Observation Tools for Teachers
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Basic Mud Logging Guide for educational purpose
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
Institutional Correction lecture only . . .
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Pharma ospi slides which help in ospi learning
Cell Structure & Organelles in detailed.
2.FourierTransform-ShortQuestionswithAnswers.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
VCE English Exam - Section C Student Revision Booklet
Computing-Curriculum for Schools in Ghana
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Cell Types and Its function , kingdom of life
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Classroom Observation Tools for Teachers
PPH.pptx obstetrics and gynecology in nursing
Basic Mud Logging Guide for educational purpose
Supply Chain Operations Speaking Notes -ICLT Program
102 student loan defaulters named and shamed – Is someone you know on the list?
Microbial diseases, their pathogenesis and prophylaxis
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Renaissance Architecture: A Journey from Faith to Humanism

2.routing in zend framework 3