PHP Classes
elePHPant
Icontem

File: manuscript/6.-Creating-new-controller.md

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Gjero Krsteski  >  PIMF  >  manuscript/6.-Creating-new-controller.md  >  Download  
File: manuscript/6.-Creating-new-controller.md
Role: Auxiliary data
Content type: text/markdown
Description: Auxiliary data
Class: PIMF
Framework for Web application development
Author: By
Last change:
Date: 10 months ago
Size: 1,000 bytes
 

Contents

Creating new controller

  • go to app/MyFirstBlog/ and create a new subdirectory Controller - the directory name is strict convention.
  • create new PHP file with name for example Blog.php into directory app/MyFirstBlog/Controller/
  • the file Blog.php has to have strict class name like MyFirstBlog\Controller\Blog and has to extend Pimf\Controller\Base
  • create new method action for example indexAction()
  • optionally you can implement the method init() - it will be triggered before any action of the controller is executed.
  • call the controller-action on sending the GET index.php?controller=blog&action=index parameters to your request

`text |-- app/ | `-- MyFirstBlog/ | |-- Controller/ | | '-- Blog.php `

Check out a sample class which shows everything you can do with a PIMF controller MyFirstBlog/Controller/Blog.php