forked from jwheare/Borax
-
Notifications
You must be signed in to change notification settings - Fork 0
mogle/Borax
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
HELLO WORLD: // app/route.class.php <?php namespace App; class Route { static function getPatterns () { return array( '/^$/' => 'home', ); } } // app/controller <?php namespace App\Controller; use Core\Controller; class HomeHtml extends Controller\Html { public function index () { $this->title = "My First Borax Page"; $this->message = "Hello World"; return $this->response; } } // app/template/home/index.tpl.php <html> <head> <title><?php out($this->title); ?></title> </head> <body> <?php out($this->message); ?> </body> </html> Now install apache-vhost.conf, fix the paths, restart apache and go! ARCHITECTURE: 1. Apache rewrites all URLs to public/index.php 2. index.php creates a web app runner (Core\Web) and calls handleRequest(); 3. App runner a) creates a dispatcher (Core\Dispatcher) with the app (App\Route) and base url routes b) encapsulates the HTTP request $request (Core\Request) c) encapsulates a user session (App\Session) and injects it into the request d) calls processRequest($request) on the dispatcher 4. Dispatcher maps the request to a controller (App\Controller) and calls generateResponse() on it 5. Controller either a) renders a template and returns a response (Core\Response) or b) throws an error or redirect (Core\HttpStatus) 6. Dispatcher returns a response (Core\Response), converting error or redirect if needed first. 7. App runner calls respond() on the response. 8. Response sets headers and echos output. FILE OVERVIEW: apache-vhost.conf // apache virtualhost configuration stub/ // Minimal stub app app/ // Full example app | |-- conf/ // Conf | --- conf.php // global conf | --- local.conf.php // local host specific conf. rename this to your system hostname, followed by ".conf.php" | |-- controller/ // Controllers | --- home.controller.php // GET / - home page | --- signout.controller.php // GET /signout - deletes session cookie and throws a redirect | --- twitter.controller.php // GET /twitter/start - throws a redirect to start twitter oauth process | // GET /twitter/callback - handles twitter oauth callback, signs in, redirects | |-- init.php // App setup/service registration | |-- lib/ // Lib directory on include path for app specific libs | --- date.class.php // Misc date helpers | |-- model/ // Models | --- person.class.php // Person database model | |-- route.class.php // Url routes | |-- schema/ // Model database schemas | --- person.mysql.sql // Person table schema | |-- script/ // Script classes that extend Core\Script |-- twitterinfo.class.php // Looks up twitter user info, optionally authenticated with a user, or manual credentials | |-- service/ // Services | --- db.service.php // mysql database | --- memcache.service.php // memcache client | --- memcached.service.php // memcached client (alternate) | |-- session.class.php // User sessions | |-- template/ // Templates | --- error.tpl.php // http errors | --- footer.inc.tpl.php // global footer | --- header.inc.tpl.php // global header | --- home/ | --- index.tpl.php // home page | --- _page/ // page templates with no controller | --- about.tpl.php // about page script/ // script runners |-- twitterinfo.php // runs the app script class |-- initdb.php // runs the core script class util.php // global php helper functions core/ // Core framework classes | |-- controller/ // Abstract controllers | --- base.class.php // Base | --- form.class.php // Form (POST) -> must redirect | --- html.class.php // HTML (GET) | --- json.class.php // Base JSON | --- jsondelete.class.php | --- jsonget.class.php | --- jsonpost.class.php | --- jsonput.class.php | --- page.class.php // Static html page (GET) | --- shared.class.php // Shared logic | |-- db.class.php // PDO wrapper | |-- dispatcher.class.php // Maps urls to controllers, passing in request objects and returning responses | |-- dump.class.php // Debug dump helper | |-- email.class.php // mb_send_mail wrapper with templating. | // writes to mail.log instead of sending if define(DISABLE_EMAILS, true); | |-- httprequest.class.php // curl wrapper | |-- httpstatus/ // HTTP status classes | --- base.class.php | --- baseerror.class.php | --- baseredirect.class.php | --- ... // Individual status classes | |-- model.class.php // ORM | |-- relationshipcache.class.php // Foreign key lookup cache | |-- request.class.php // Incoming HTTP request wrapper | // Wraps $_GET $_POST $_COOKIE and $_SERVER | |-- response/ // Response classes | --- base.class.php | --- html.class.php | --- htmlerror.class.php | --- json.class.php | --- jsonerror.class.php | --- redirect.class.php | |-- script.class.php // Script class, with helpers for handling command line args |-- initdbscript.class.php // Creates a new database and username | |-- servicemanager.class.php // Static global services manager | |-- session.class.php // Base Session class. Wraps $_SESSION. Manages cache headers | |-- twitter.class.php // Twitter API client | |-- url.class.php // URL encoding, building, parsing class | |-- web.class.php // Web app runner init.php // Framework initialisation # Web document root public/ // Put non static and non framework files in here |-- index.php // Delegates to web app runner
About
PHP web framework
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published
Languages
- PHP 100.0%