2017 © Pedro Peláez
 

library project

Web Skeleton Application for bootphp

image

bootphp/project

Web Skeleton Application for bootphp

  • Tuesday, July 11, 2017
  • by lnt
  • Repository
  • 1 Watchers
  • 0 Stars
  • 23 Installations
  • ApacheConf
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 10 % Grown

The README.md

BootPHP

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., (*1)

Pre-requisite

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, (*2)

-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., (*3)

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, (*4)

Tweakings

To build project/clear cache/rebuild annotations - Hit this URL from Browser, (*5)

    http://localhost/?RX_MODE_BUILD=TRUE&RX_MODE_DEBUG=TRUE

The Versions

11/07 2017

dev-master

9999999-dev

Web Skeleton Application for bootphp

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

11/07 2017

0.0.0

0.0.0.0

Web Skeleton Application for bootphp

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires