Dear astonecipher, JimL and benanemen,
I’ve started reading about routers and controllers. I’ve taken code from a tutorial and i’m trying to understand it. I wish to make my own router and controller without a framework dependency. I can learn more building my own. However, i need some guidance along the way. Please try to help me if you have the time and patience to do so.
i want to make a skeleton website using a router and a controller with an autoload file. Then i will take my current website and work it into this skeleton. Thus, my first question is the config of the index.php file.
index.php
<?php
$GLOBALS["config"] = array(
"appName" => "NatureSite",
"domain" => "localhost",
"path" => array(
"app" => "app/",
"core" => "core/",
"index" => "index.php"),
"defaults" => array(
"controller" => "main",
"method" => "index"),
"routes" => array(),
"database" => array(
"host" => "localhost",
"username" => "",
"password" => "",
"name" => "")
);
require_once $GLOBALS["config"]["path"]["core"]."autoload.php";
?>
this code was shown in a tutorial. I’ve changed only the appName to NatureSite.
so as a skeleton site, i will have the following setup:
htdocs:
index.php
[css] .css files
[js] .js files
[img] .jpg and .png images
[about] index.php
[legal] index.php
[subscribe] form.php processform.php
[nature] -> [aves] -> [brachycera] -> [arachnida] -> [fungi] -> etc.
i was told that i do not need to build folders for each species, such as,
nature -> animalia -> vertebrata -> aves -> turdidae -> turdus -> migratorius -> index.php
so i ask how to modify the index.php file from the tutorial to work with my website.
in this code:
"path" => array(
"app" => "app/",
"core" => "core/",
"index" => "index.php"),
do i place the directory names with array names?
so based upon my skeleton: css folder needs to be added to the path array as “style” => “css/”,? is this correct? so my path array should be as follows:
"path" => array(
"style" => "css/",
"script" => "js/",
"images" => "img/",
"about" => "about/",
"laws" => "legal/",
"join" => "subscribe/",
"content" => "nature/",
"index" => "index.php"),
is this correct? my website structure belongs in the path array, yes?
Thank you for your time.