rudrax/boot
Composer 安装命令:
composer require rudrax/boot
包简介
Suporting library for Rudrax
关键字:
README 文档
README
Simple and Light weight MVC framework in PHP, it serves all stable functionalties like routing (native), caching (phpFastCache), database (Redbeans & PDO), templating (Smarty), authentication (Basic,SSO & Custom), Session/Roles etc.
Setup
Prerequisites
- XAMP : instructions
- PHP/Copmoser : instructions
Setup New RudraX Project
If you are starting a fresh project simply follow these steps
- Go to directoy where you want to create your project lests say "/Users/Lucas/Projects/" and run this command
$ composer create-project rudrax/project my_project
Or you can Manually Setup RudraX project or install RudraX in your existing project
Install in existing project
$ composer install rudrax/boot --save
Folder Structure
If you have used create-project command then this directory structure will be automatically created for you. Otherwise create it manually. and make sure build folder has correct permisson 0777
-app
L controller // Controller/URL Mapping for Project, name of file and class should match
L model //Models being Used in Porject
L view //Smart Templates
-config
L project.properties //Project Properties
-build // Build/Temporary Files created by Framwork, need write permissions
-src // Folder for static files like javascript,html,css
-lib // composer library folder
-index.php
.htaccess
-composer.json // set config->vendor-dir = lib
index File [index.php]
This file also gets created automatically if you have used create-project. Otherwise create it and copy the code in file, also copy .htaccess in you project.
ini_set('display_errors', 'On');
ini_set('error_reporting', E_ALL);
error_reporting(E_ALL);
error_reporting(E_ALL & ~E_DEPRECATED);
require("./lib/autoload.php");
require_once("./lib/rudrax/boot/RudraX.php");
RudraX::invoke(array(
'RX_MODE_MAGIC' => TRUE,
'RX_MODE_DEBUG' => FALSE,
'PROJECT_ROOT_DIR' => "./"
));
Documentaion
Now we are done with setup, lets start with how to write code in our project.
Sample Controller [app/controller/MyController.php]
namespace app\controller { class MyController extends AbstractController { /** * @RequestMapping(url="login",method="GET",type="template") * @RequestParams(true) */ public function login($model,$username,$password) { if($username == "user1" && $password == "xDddfdfd"){ $this->user->setValid(TRUE); $this->user->role = "USER"; $model->assign("username", $username); return "welcome"; // 'welcome' is path of smarty tempalte file in view folder } else { $this->user->setValid(FALSE); $model->assign("error", "Wrong credentials"); return "login"; // 'login' is path of smarty tempalte file in view folder } } /** * @RequestMapping(url="myprofile",method="GET",type="template") * @RequestParams(true) */ public function myprofile($model) { if($this->user->isValid()){ $model->assign("username", $this->user->uname); return "user/myprofile"; // 'user/myprofile' is path of smarty tempalte file in view folder } else { $this->user->setValid(FALSE); $model->assign("error", "You need to login to view this page"); return "login"; // 'login' is path of smarty tempalte file in view folder } } /** * @RequestMapping(url="info/school/{category}",method="GET",type="json") * @RequestParams(true) */ public function schoolinfo($category) { if($this->user->isValid()){ return array( "success" => true, "id" => 23,"name"=>"DAV Public School"); } else { return array("success" => false,"error"=> "You need to login to view this info"); } } } }
Controller Annotation Options
All are method level annotations
- @RequestMapping - URL info - url - url pattern to match - method - request method [GET|POST|PUT|DELETE] - used only if mentioned - type - response type [template|json|data] - data - auth - if url acccess requires basic auth [TRUE|FALSE] - FALSE - cache - if response is cacheable by server [TRUE|FALSE] - FALSE - guestcache - cacheable only if guest user (user not valid) [TRUE|FALSE] - FALSE
- @RequestParams - if query params to be fetched and used in controller. [TRUE|FALSE] - FALSE
- @Role - [user defined values] - used only if mentioned, users with matching $user->{role} will have access to api.
Model Annotation Options
Class Level Annotations
- @Model - [sessionUser] -
- sessionUser - if used then that model will be used as default Session user, Class must extend app\model\AbstractUser
Tweakings
To build project/clear cache/rebuild annotations - Hit this URL from Browser
http://localhost/?RX_MODE_BUILD=TRUE&RX_MODE_DEBUG=TRUE
rudrax/boot 适用场景与选型建议
rudrax/boot 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.54k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 09 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「smarty」 「controller」 「rudra」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rudrax/boot 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rudrax/boot 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rudrax/boot 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Give your JS App some Backbone with Models, Views, Collections, and Events.
Rewritten Smarty foreach variant that was invented for use in xoops, but nowadays is used in some other PHP based CMS'es
A PSR-7 compatible library for making CRUD API endpoints
Modified Smarty for Rudrax
Modified Smarty for Rudrax
redbeanphp service for Rudrax
统计信息
- 总下载量: 2.54k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 3
- 推荐数: 4
其他信息
- 授权协议: MIT
- 更新时间: 2015-09-19