2017 © Pedro Peláez
 

library shadow_framework

Shadow MVC Framework v0.1

image

zarna0x/shadow_framework

Shadow MVC Framework v0.1

  • Tuesday, June 12, 2018
  • by Zarna0x
  • Repository
  • 1 Watchers
  • 1 Stars
  • 16 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 14 % Grown

The README.md

Shadow MVC Framework v0.1

alt tag, (*1)

Build Status, (*2)

license, (*3)

Installation

Install using composer, (*4)

composer create-project zarna0x/shadow_framework myproject

or you can clone git repository, (*5)

git clone https://github.com/Zarna0x/Shadow-mvc-framework.git

and, (*6)

composer install

Features

ShadowPHP is simple and flexible mvc framework which provides various features just out of the box, Such as:, (*7)

  • Models
  • Views
  • Controllers
  • Custom routes
  • Command line tool
  • Request handling
  • Session handling
  • Flash Messages/Sessions
  • Input validation

.etc, (*8)

furthermore you can add your own features and libraries, (*9)

console.shadow

You can create models and controllers from your terminal using console.shadow just type:, (*10)

php console.shadow

alt tag, (*11)

This command will generate controller with name GitShadow, (*12)

GitShadow.php:, (*13)

 

Define Routes

ShadowPHP has advanced routing capabilities and user can define custom routes(Located in sh_http/Routes.php). You can define route this way:, (*14)

use ShadowApp\Sys\Router as ShadowRouter;

ShadowRouter::define('/home',[
   'controller' => 'index',
   'method'     => 'hello'
]);

ShadowRouter::run();

OR, (*15)

ShadowRouter::define('/register',function(){
   echo "This Is Register"
});

Also you can pass variable to view, (*16)

ShadowRouter::define('/somelink',function(){
    ShadowApp\Sys\View::run('rame/index',[
       'var' => 'just some random text'
    ]);
});

Requests

Youn can handle http requests using ShadowPHP's Shadowapp\Sys\Requester class:, (*17)

use \Shadowapp\Sys\Requester as Requester;

1) check if request method is post, (*18)

Requester::isPost();

2) check if request method is Get, (*19)

Requester::isGet();

3) get parameters of post request, (*20)

Requester::getPost('name');

4) redirect user, (*21)

Requester::redirect('home');

5) Retrieve All Input Data, (*22)

Requester::all();

Session

Shadowapp\Sys\Session class provides object-oriented wrapper of session data ., (*23)

1) start Session, (*24)

use \Shadowapp\Sys\Session as Session

Session::start('auth', [
                  'id'   => user->id,
                  'name' => $user->name
               ]);

2) get session, (*25)

Session::get('auth');

3) destroy session, (*26)

Session::smash();

4) remove session, (*27)

Session::remove('auth');

5) check if specified key is set, (*28)

Session::has('auth');

Flash Messages

Flash Session temporarily stores the messages in session, then messages can be printed in the next request, (*29)

 Session::flashShadow('error','Wrong Username Or Password');
 Requester::redirect('login');

and, (*30)

  if(Shadowapp\Sys\Session::has('error'))
  {
      Shadowapp\Sys\Session::flashOutput('error');
  }

Validation

ShadowPHP has easy and flexible approach to validate your application's incoming requests just use Shadowapp\Sys\Validator class, (*31)

Create Validator, (*32)

 use \Shadowapp\Sys\Validator as Validator; 

Validator::run(Requester::all(),[
              'name' => [
                 'required' => true,
                 'min' => 3,
                 'max' => 10,
                 'empty'  => false
               ],
              'pass' => [
                 'requred' => true,
                 'min'     => 3,
                 'max'     => 20,
              ]
           ]);

Check if there is any validation error and redirect user with flash session, (*33)

  if(Validator::failed())
    {
              Session::flashShadow('error',Validator::errorMessage());
              Requester::redirect('login');
              return;
    }

The Versions

12/06 2018

dev-master

9999999-dev

Shadow MVC Framework v0.1

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Zarna0x

12/04 2017

v0.1

0.1.0.0

Shadow MVC Framework v0.1

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Zarna0x