-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
128 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Options -Indexes | ||
|
||
<IfModule mod_rewrite.c> | ||
|
||
RewriteEngine On | ||
RewriteBase / | ||
|
||
# Force to exclude the trailing slash | ||
RewriteCond %{REQUEST_FILENAME} !-d | ||
RewriteCond %{REQUEST_URI} (.*)/$ | ||
RewriteRule ^(.+)/$ $1 [R=307,L] | ||
|
||
# Restrict php files direct access | ||
RewriteCond %{THE_REQUEST} ^.+?\ [^?]+\.php[?\ ] | ||
RewriteRule \.php$ - [F] | ||
|
||
# Allow any files or directories that exist to be displayed directly | ||
RewriteCond %{REQUEST_FILENAME} !-f | ||
RewriteCond %{REQUEST_FILENAME} !-d | ||
|
||
RewriteRule ^(.*)$ index.php?$1 [QSA,L] | ||
|
||
</IfModule> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
if (file_exists('vendor/autoload.php')) { | ||
require 'vendor/autoload.php'; | ||
} else { | ||
echo "<h1>Please install via composer.json</h1>"; | ||
echo "<p>Install Composer instructions: <a href='https://getcomposer.org/doc/00-intro.md#globally'>https://getcomposer.org/doc/00-intro.md#globally</a></p>"; | ||
echo "<p>Once composer is installed navigate to the working directory in your terminal/command promt and enter 'composer install'</p>"; | ||
exit; | ||
} | ||
|
||
if (!is_readable('app/Core/Config.php')) { | ||
die('No Config.php found, configure and rename Config.example.php to Config.php in app/Core.'); | ||
} | ||
|
||
/* | ||
*--------------------------------------------------------------- | ||
* APPLICATION ENVIRONMENT | ||
*--------------------------------------------------------------- | ||
* | ||
* You can load different configurations depending on your | ||
* current environment. Setting the environment also influences | ||
* things like logging and error reporting. | ||
* | ||
* This can be set to anything, but default usage is: | ||
* | ||
* development | ||
* production | ||
* | ||
* NOTE: If you change these, also change the error_reporting() code below | ||
* | ||
*/ | ||
define('ENVIRONMENT', 'development'); | ||
/* | ||
*--------------------------------------------------------------- | ||
* ERROR REPORTING | ||
*--------------------------------------------------------------- | ||
* | ||
* Different environments will require different levels of error reporting. | ||
* By default development will show errors but production will hide them. | ||
*/ | ||
|
||
if (defined('ENVIRONMENT')) { | ||
switch (ENVIRONMENT) { | ||
case 'development': | ||
error_reporting(E_ALL); | ||
break; | ||
case 'production': | ||
error_reporting(0); | ||
break; | ||
default: | ||
exit('The application environment is not set correctly.'); | ||
} | ||
} | ||
|
||
//initiate config | ||
new Core\Config(); | ||
|
||
//create alias for Router | ||
use Core\Router; | ||
use Helpers\Hooks; | ||
use Helpers\Session; | ||
|
||
//define routes | ||
Router::any('', 'Controllers\Welcome@index'); | ||
|
||
//module routes | ||
$hooks = Hooks::get(); | ||
$hooks->run('routes'); | ||
|
||
//if no route found | ||
Router::error('Core\Error@index'); | ||
|
||
//turn on old style routing | ||
Router::$fallback = false; | ||
|
||
Session::init(); | ||
if (Session::get('lang') == false) { | ||
Session::set('lang', 'en'); | ||
} | ||
define('LANGUAGE_CODE', Session::get('lang')); | ||
|
||
//execute matched routes | ||
Router::dispatch(); |