fernandopetry / mvc
管理 MVC 调用
1.0.3
2018-06-11 17:07 UTC
Requires
- php: >=5.6
Requires (Dev)
- phpunit/phpunit: ~5.0
This package is not auto-updated.
Last update: 2024-09-26 19:43:07 UTC
README
htaccess 示例
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?router=/$1 [QSA,L] </IfModule>
用法 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
用法 2 | 门面
<?php use \Petry\MVC\Uri\UriFacade; $facade = new UriFacade('router'); $facade->getController(); // Controller $facade->getAction(); // Action $facade->getParams(); // Params
安装 composer
$ composer require fernandopetry/mvc
使用 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(); }