-
Notifications
You must be signed in to change notification settings - Fork 0
index.php
LaCodon edited this page Dec 16, 2015
·
4 revisions
This file is very important for a Famework project. It's called on any request and responsible for basic bootstrapping as well as running the actual Controller, Action and View.
Template:
<?php
use Famework\Famework;
use Famework\Config\Famework_Config;
use Famework\Registry\Famework_Registry;
// the root folder of the application
define('APPLICATION_PATH', __DIR__ . DIRECTORY_SEPARATOR);
// the root folder to use in URLS; usually you can keep this as it is
define('HTTP_ROOT', str_replace(basename(__FILE__), '', $_SERVER['PHP_SELF']) . '/');
// the path to your /view folder
define('VIEW_PATH', APPLICATION_PATH . 'view');
// require Famework; yes, that's it! REPLACE THIS with the path to your Famework.php
require '/path/to/your/Famework/folder/Famework.php';
// activate error_reporting and define default error and exception handlers
// you can replace this with your own handlers
// DEACTIVATE error_reporing on production
error_reporting(E_ALL | E_STRICT);
Famework::registerDefaultHandler();
// Famework::ENV_PROD for producation
// this is just a nice constant
Famework_Registry::setEnv(Famework::ENV_DEV);
// initialize Famework
$famwork = new Famework(new Famework_Config(APPLICATION_PATH . '../config/config.ini'), new Famework_Config(APPLICATION_PATH . '../config/routes.ini'));
// this require statement is the simplest autoloader on earth, replace it with your own
require './controller/IndexController.php';
// handle request and load controller, because this is MVC pattern!
$famwork->handleRequest();
$famwork->loadController();
- Home
- Getting Started
- Server Setup
- Configuration Files
- Application Structure
- Classes