Manage mvc calls

1.0.3 2018-06-11 17:07 UTC

This package is not auto-updated.

Last update: 2024-05-09 17:55:29 UTC


README

Exemplo de htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?router=/$1 [QSA,L]
</IfModule>

Usage 1

<?php
use \Petry\MVC\Uri\Parse;
use \Petry\MVC\Uri\Param;
use \Petry\MVC\Uri\GetByURI;

$uri = new GetByURI('router');
$param = new Param($uri);
$parse = new Parse($param);

$parse->getController(); // Controller
$parse->getAction(); // Action
$parse->getParams(); // Params

Usage 2 | Facade

<?php
use \Petry\MVC\Uri\UriFacade;

$facade = new UriFacade('router');
$facade->getController(); // Controller
$facade->getAction(); // Action
$facade->getParams(); // Params

Install composer

$ composer require fernandopetry/mvc

Usage ControllerFactory

<?php

use \Petry\MVC\Uri\UriFacade;

try {
    $factory = new \Petry\MVC\Controller\ControllerFactory(new UriFacade('router'),'Petry\Test\Controller');
    $factory->factory();
}catch (Exception $e){
    echo $e->getMessage();
}