Skip to content

sbstjn/php-kickstart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

I wanted to create a simple PHP framework with easy Request and Response access, automated Jade template parsing and LESS stylesheet generating. I tried to adapt some of the routing syntax of Express.js for php-kickstart route definition.

Defining Routes

For handling new routes you need a Router with a new Request and Response, all access to needed functions is later handled through those response and request objects.

<?php

$Router = new Router(new Request(), new Response());

$Router->get('/')->bind('General', 'home');
$Router->get('/download/:file/:type')->bind('General', 'download');

Create a custom handle in handles/ with classname General and both methods home and download like handles/General.class.php:

<?php

class General {

  public function home(&$req, &$res) {
    $res->render('home');
  }
  
  public function download(&$req, &$res) {
    $res->assign('file', $req->param('file'));
    $res->assign('type', $req->param('type'));
  
    $res->render('download');
  }  

}

The response handler will search for templates in views/ matching the name by adding .jade, .mustache or any other registered template engine as file extension.

!!! 5
html
  head
    meta(http-equiv='content-type', content='text/html; charset=utf-8')
    title php–kickstart
  body
    p Downloading #{file}
      | as #{type}
    p Downloading #{file} as #{type}      

About

Environment for rapid PHP development. Includes Jade and LESS parsing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages