gelembjuk/webapp
Composer 安装命令:
composer require gelembjuk/webapp
包简介
PHP MVC Package for rapid building of web sites with HTML/AJAX/RESP API functionality
README 文档
README
PHP MVC Package for rapid building of web sites with HTML/AJAX/RESP API functionality
Installation
Using composer: gelembjuk/webapp require: {"gelembjuk/webapp": "*"}
Usage
This is simplest "one file" example of an app usage. On practive you will have separate folders for Controllers,Views and Models
// ==================== CONFIGURATION ================================== // path to your composer autoloader require ('vendor/autoload.php'); $thisdirectory = dirname(__FILE__) . '/'; // get parent directory of this script // application settings class appConfig { public $offline = false; public $loggingfilter = 'all'; // log everything } // application options $options = array( 'webroot' => $thisdirectory, 'tmproot' => $thisdirectory.'tmp/', 'relativebaseurl' => '/example/2/', // this option is useful only if default Router is used. 'loggerstandard' => true, 'applicationnamespace' => '\\', 'defaultcontrollername' => 'MyController', 'htmltemplatespath' => $thisdirectory.'template/', 'htmltemplatesoptions' => array('extension' => 'htm') // our templates will have HTML extension ); // ==================== APPLICATION LOGIC ================================== // controller class class MyController extends \Gelembjuk\WebApp\Controller { // viewer name. protected $defviewname = 'MyViewer'; // ========= the only action of the controler protected function doSendmessage() { // do somethign to send message // best is to use a model // if this was JSON request then we will return success status // if normal web request then we will redirect to home page return array('success',$this->makeUrl(array('message' => 'Successfully sent'))); } } // view class class MyViewer extends \Gelembjuk\WebApp\View{ protected function view() { // just display default page $this->htmltemplate = 'default'; $this->viewdata['welcomemessage'] = 'Hello there!'; return true; } protected function viewForm() { // display form page $this->htmltemplate = 'form'; return true; } protected function viewData() { // display form page $this->htmltemplate = 'data'; // template name // usually it can be loaded from a Model $this->viewdata['data'] = array( array('name'=>'User1','email'=>'email1@gmail.com'), array('name'=>'User2','email'=>'email2@gmail.com'), array('name'=>'User3','email'=>'email3@gmail.com'), ); return true; } protected function beforeDisplay() { // set some extra information for any page if ($this->responseformat == 'html') { // only if this is html format to display $this->viewdata['applicationtitle'] = 'Demo application'; // include more data that should be displayed on any page of a site } return true; } } $application = \Gelembjuk\WebApp\Application::getInstance(); $application->init(new appConfig(),$options); $application->action();
Author
Roman Gelembjuk (@gelembjuk)
gelembjuk/webapp 适用场景与选型建议
gelembjuk/webapp 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 78 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 10 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 gelembjuk/webapp 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gelembjuk/webapp 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 78
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-10-08