Skip to content

Instantly share code, notes, and snippets.

@graphis
Last active September 14, 2015 10:57
Show Gist options
  • Save graphis/35b6fd0cf60347b0f510 to your computer and use it in GitHub Desktop.
Save graphis/35b6fd0cf60347b0f510 to your computer and use it in GitHub Desktop.
root/index.php -- simple application bootstrap with some $path variables
RewriteEngine On
RewriteRule ^$ index.php [QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
<?php
/**
*
* index.php -- skeleton
* index.php is responsible to set up application enviroment paths,
* composer autoloader, and call bootstrap
*
* @package my_application
* @version 1.0
* @license http://opensource.org/licenses/bsd-license.php BSD
* @copyright 2015 Zsolt Sándor
*
*/
// usage: index.php in htaccess
/*
RewriteEngine On
RewriteRule ^$ index.php [QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
*/
/**
* Relative path to the application directory.
*/
$application = '../Application/';
/**
* Relative path to the framework core. For hideing ugly vendor path
*/
$system = '../system';
/**
* Set the PHP error reporting level. If you set this in php.ini, you remove this.
* Dev: E_ALL | E_STRICT
* Production: E_ALL ^ E_NOTICE
* PHP >= 5.3 E_ALL & ~E_DEPRECATED
*/
error_reporting(E_ALL | E_STRICT);
// Set the full path to the docroot
define('DOCROOT', realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR);
// Make the application relative to the docroot, for symlink'd index.php
if ( ! is_dir($application) AND is_dir(DOCROOT.$application))
$application = DOCROOT.$application;
// Make the system relative to the docroot, for symlink'd index.php
if ( ! is_dir($system) AND is_dir(DOCROOT.$system))
$system = DOCROOT.$system;
// Define the absolute paths for configured directories
define('APPPATH', realpath($application).DIRECTORY_SEPARATOR);
define('SYSPATH', realpath($system).DIRECTORY_SEPARATOR);
// Clean up the configuration vars
unset($application, $system);
// Kickstart the framework
require SYSPATH.'vendor/autoload.php';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment