File: app/example/controller/maincontroller.class.php

Recommend this page to a friend!
  Classes of Carlos Eduardo Barcelos Amaral  >  Base MVC Framework  >  app/example/controller/maincontroller.class.php  >  Download  
File: app/example/controller/maincontroller.class.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Base MVC Framework
MVC framework to be the base of Web applications
Author: By
Last change: Merge branch 'master' of https://github.com/KaduAmaral/Base
Date: 4 years ago
Size: 1,032 bytes
 

Contents

Class file image Download
<?php
namespace Controller;

use \
Core\Controller;

/**
* Main Controller
*/
class MainController extends Controller {

  
/**
    * @Route("/", {"name":"index", "allows":"GET|POST"})
    * @return mixed
    */
  
public function index(){
      return
$this->load->view('pages/index');
   }

  
/**
    *
    * @Route("/post/:id", {"params":{"id":"\d+"}})
    *
    * @param $id
    * @param string $nome
    * @return string
    */
  
public function teste($id, $nome = 'Fulano') {
      return
"Olá $nome, o ID é {$id}";
   }


  
/**
    * @Route("/acao/:slug", {"name":"acao", "params":{"slug":"[a-zA-Z0-9\-_]"}})
    *
    * @param $slug
    * @return string
    */
  
public function action($slug) {
      return
"Post: {$slug}";
   }

  
/**
    * @Route("/post/:date/:slug", {"params":{"date":"[0-9]{2}-[0-9]{2}-[0-9]{4}", "slug":"[a-zA-Z0-9\-_]"}})
    *
    * @param $date
    * @param $slug
    * @return string
    */
  
public function pdate($date, $slug) {
      return
"Postagem: {$slug}<br>Data: {$date}";
   }
}

For more information send a message to info at phpclasses dot org.