clagiordano/weblibs-mvc
Composer 安装命令:
composer require clagiordano/weblibs-mvc
包简介
weblibs-mvc is an simple and lightweight php routing component.
README 文档
README
weblibs-mvc
weblibs-mvc is an simple and lightweight php routing component. This component can have a RESTful support simply adding an .htaccess file, see below for more details.
Based on http://php-html.net/tutorials/model-view-controller-in-php/
Based on http://phpro.org/tutorials/Model-View-Controller-MVC.html#9
Description of the main components
Application
The application class is the main component wich handle and relates components between them.
Controller
The Controller is the C in MVC. The base controller is a simple abstract class that defines the structure of all controllers. By including the registry here, the registry is available to all class that extend from the base controller. An index() method has also been included in the base controller which means all controller classes that extend from it must have an index() method themselves.
Registry
The registry is an object where site wide variables can be stored without the use of globals. By passing the registry object to the controllers that need them, we avoid pollution of the global namespace and render our variables safe. We need to be able to set registry variables and to get them.
Routing
The router class is responsible for loading up the correct controller. It does nothing else. The value of the controller comes from the URL.
Template
The templates themselves are basically HTML files with a little PHP embedded. Do not let the separation Nazi's try to tell you that you need to have full separation of HTML and PHP. Remember, PHP is an embeddable scripting language. This is the sort of task it is designed for and makes an efficient templating language. The template files belong in the views directory.
Installation
The recommended way to install weblibs-mvc is through Composer.
composer require clagiordano/weblibs-mvc
Adding RESTful support to destination project
Simply add into yours project root a file named .htaccess
(webserver must be allow override) which contains the following lines:
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?rt=$1 [L,QSA]
this simple steps allow your application make RESTful calls like:
http://www.example.com/clients/68563 http://www.example.com/access/login http://www.example.com/chart/ http://www.example.com/products/6574
Usage
/** * Composer autoload */ require_once __DIR__ . '/vendor/autoload.php'; /** * Import required classes */ use clagiordano\weblibs\mvc\Application; use clagiordano\weblibs\mvc\Registry; use clagiordano\weblibs\mvc\Router; use clagiordano\weblibs\mvc\Template; /** * Init base application * @var Application $application */ $application = new Application(); /** * Router setup */ $application->setRouter( new Router($application) ); /** * set the path to the controllers directory */ $application->getRouter()->setControllersPath( __DIR__ . '/controllers' ); /** * Template setup */ $application->setTemplate( new Template($application) ); /** * load the controller / run the application */ $application->getRouter()->loader();
Legal
Copyright (C) Claudio Giordano claudio.giordano@autistici.org
clagiordano/weblibs-mvc 适用场景与选型建议
clagiordano/weblibs-mvc 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 87 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 03 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「routing」 「api」 「restful」 「mvc」 「clagiordano」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 clagiordano/weblibs-mvc 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 clagiordano/weblibs-mvc 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 clagiordano/weblibs-mvc 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
Write down your routing mapping at one place
A PSR-7 compatible library for making CRUD API endpoints
Flight routing is a simple, fast PHP router that is easy to get integrated with other routers.
Client for Google Directions API to add interpolated points to a route consisting of given coordinates.
A router designed for web requests for the Monolith framework
统计信息
- 总下载量: 87
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0
- 更新时间: 2016-03-31