bootphp / project
Web Skeleton Application for bootphp
0.0.0
2017-07-11 13:19 UTC
Requires
- php: >=5.5.0
Requires (Dev)
- boilerplatez/docs: dev-master
This package is auto-updated.
Last update: 2024-10-17 02:11:50 UTC
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.
Pre-requisite
- XAMPP instructions
- PHP/Copmoser instructions
Setup
$ composer create-project bootphp/project my_project
$ cd my_project
$ composer update
$ composer require bootphp/rudrax
Build
- Whenever there are changes in Any Controller-Annotations you need to hit this url
http://local.piggy.com?RX_MODE_DEBUG=true&RX_MODE_BUILD=1&_display_errors_=2
Working?
- Hit these urls in your browser and see the outputs you get
http://local.piggy.com/welcome?name=Lucas
http://local.piggy.com/api/data/7
http://local.piggy.com
Documentation
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
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