Hello PHP World, I am a beginner back-end programmer. I have very limited knowledge and experience. However, i should still be able to make a website if i want to do so. I often feel that tech giants, or powers that be, try to control us with learning curves. I can design an html and css website but i need backend power to create a viable business, albeit small business. My lack of knowledge keeps getting in the way. I often receive tips to use frameworks which i find to be cumbersome and more like inhibitors to my html css designs. Everytime i read about how to use a framework, i leave the page in seconds. I do not want to attend a university to build a PHP login website. My point here is that i am trying to learn about routing, controllers and frameworks on my own. Today, i have tried to think about this concept and try some things to see what works. I discovered something that is very problematic and i seek an answer to this problem:
i have enabled the Apache Rewrite engine and set conditions as follows:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
I understand this to mean “if file or directory does not exist, then send to index.php” and this is how it works. Originally, i thought that all traffic is routed to index.php but the not symbol is pretty clear now.
Meantime, i wanted to see how one could capture a fake link. Thus, i came up with the following code (this is just test code to see what happens). So index.php:
<?php
$street = $_SERVER['REQUEST_URI'];
$streetMap = explode("/", parse_url($street, PHP_URL_PATH));
$street = NULL;
if ($streetMap[1] == "OneStr") {
echo "Street One<br />";
echo "<a href=\"/\">Return to index</a>";
exit;
} else {
?>
<html>
<head>
<title></title>
</head>
<body>
<a href="OneStr/">Street One</a><br />
</body>
</html>
<?php
}
exit;
?>
if i exclude the if else block, then every time the OneStr link is clicked, the fake directory name is added to the address bar. Eventually, Apache throws an error because the string has exceeded a limit. When i add a handler for the fake directory, the fake directory no longer gets appended to the address each time it is clicked. Is Apache still cycling this fake dir? so, even with the fakedir handler, Apache will still crash when it reaches the limit? Then, how does a router/controller work? what am i not understanding? or is this correct?
Also, i have no idea why we all cannot build an easier template to replace frameworks. I think of a website like this:
website=town, folders=streets, pages=addresses/buildings/houses, session=vehicle/auto, user=driver
all autos have a vin number, a tag, a tag expiration, must have a valid registration, some have inspection stickers etc.
all drivers must have a driver license, a registration, insurance, etc
police cruise the town looking for traffic violations etc and can call dispatch (database) for suspect details etc.
i hope to start a github where programmers can make this happen. Web design should be easier and faster and still secure.
Anyway, am i on the right path to understanding routers or not?