Skip to content

Commit

Permalink
changes...
Browse files Browse the repository at this point in the history
  • Loading branch information
d4rkfly3r committed Aug 16, 2015
1 parent a88a5e3 commit 17a5081
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 5 deletions.
23 changes: 23 additions & 0 deletions .htaccess
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>
27 changes: 22 additions & 5 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 83 additions & 0 deletions index.php
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();

0 comments on commit 17a5081

Please sign in to comment.