upload files
upload files
This commit is contained in:
parent
c09133545f
commit
e5bb5403ea
7
config/database.ini
Normal file
7
config/database.ini
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
[database]
|
||||||
|
db_driver = mysql
|
||||||
|
db_host = localhost
|
||||||
|
db_name = foo
|
||||||
|
db_username = foo
|
||||||
|
db_password = bar
|
||||||
|
filedb_storage = ./storage
|
39
index.php
Normal file
39
index.php
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* VerySimplePHPFramework
|
||||||
|
* Go Namhyeon <gnh1201@gmail.com>
|
||||||
|
* Date: 2017-12-18
|
||||||
|
*/
|
||||||
|
|
||||||
|
// including vendor autoloader
|
||||||
|
include_once('./vendor/autoload.php');
|
||||||
|
|
||||||
|
// system files
|
||||||
|
include_once('./system/config.php');
|
||||||
|
include_once('./system/database.php');
|
||||||
|
|
||||||
|
// route controller
|
||||||
|
$route = '';
|
||||||
|
if(array_key_exists('route', $_REQUEST)) {
|
||||||
|
$route = $_REQUEST['route'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(empty($route)) {
|
||||||
|
$route = 'welcome';
|
||||||
|
} else {
|
||||||
|
$route_names = explode('/', $route);
|
||||||
|
if(count($route) > 1) {
|
||||||
|
$route = end($route_names);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// view render
|
||||||
|
function renderView($name) {
|
||||||
|
$viewfile = './view/' . $name . '.php';
|
||||||
|
if(file_exists($viewfile)) {
|
||||||
|
include('./view/' . $name . '.php');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// including route file
|
||||||
|
include('./route/' . $route . '.php');
|
3
route/welcome.php
Normal file
3
route/welcome.php
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
renderView('welcome');
|
13
system/config.php
Normal file
13
system/config.php
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
$config = array();
|
||||||
|
if($handle = opendir('./config')) {
|
||||||
|
while (false !== ($file = readdir($handle))) {
|
||||||
|
if ($file != "." && $file != ".." && end(explode('.', $file)) == 'ini') {
|
||||||
|
$ini = parse_ini_file('./config/' . $file);
|
||||||
|
foreach($ini as $k=>$v) {
|
||||||
|
$config[$k] = $v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir($handle);
|
||||||
|
}
|
12
system/database.php
Normal file
12
system/database.php
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
$conn = new PDO(
|
||||||
|
sprintf(
|
||||||
|
"mysql:host=%s;dbname=%s;charset=utf8",
|
||||||
|
$config['db_host'],
|
||||||
|
$config['db_name']
|
||||||
|
),
|
||||||
|
$config['db_username'],
|
||||||
|
$config['db_password'],
|
||||||
|
array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")
|
||||||
|
);
|
||||||
|
$conn->query("SET NAMES 'utf8'");
|
11
vendor/autoload.php
vendored
Normal file
11
vendor/autoload.php
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<?php
|
||||||
|
define("VENDOR_PATH", './vendor');
|
||||||
|
|
||||||
|
// class loader
|
||||||
|
function my_autoloader($className) {
|
||||||
|
if(!class_exists($className)) {
|
||||||
|
$classFileName = str_replace("\\", "/", $className);
|
||||||
|
include_once(VENDOR_PATH . '/' . $classFileName . '.php');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
spl_autoload_register('my_autoloader');
|
2
view/template/footer.php
Normal file
2
view/template/footer.php
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
<p>This is header</p>
|
||||||
|
<p>http://github.com/gnh1201/verysimplephpframework</p>
|
1
view/template/header.php
Normal file
1
view/template/header.php
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<p>this is footer</p>
|
3
view/welcome.php
Normal file
3
view/welcome.php
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
Welcome!
|
||||||
|
|
||||||
|
VerySimplePHPFramework
|
Loading…
Reference in New Issue
Block a user