Basic Utilities
From Photon Framework
Web Utilities
web/PageControllerApp
PageControllerApp let's you serve a web application in a page-controller style. The constructor takes as first parameter the location of your pages (tipically APPROOT/pages). To serve a page, call the run method with the path to the page: <source lang="php"> require 'photon/web/PageControllerApp'; $app = new PageController(APPROOT.'/pages'); $app->run('/path/to/my_page'); // relative to the path passed to the constructor </source>
This will open the file APPROOT/pages/path/to/my_page.php which should contain an class named MyPage which extends Page. It will instantiate the page, and call the render method:
APROOT/pages/path/to/my_page.php <source lang="php"> <?php class MyPage extends Page {
function render () {
echo "Hello World!";
}
} </source>
If there is an action parameter (in $_GET or $_POST), the corresponding method on the page will be called before the render method.
APPROOT/pages/path/to/my_page.php <source lang="php"> <?php class MyPage extends Page {
// this will be called if there's an action=updateSession GET or POST parameter
function updateSession () {
// perform some action
}
function render () {
echo "Hello World!";
}
} </source>
