This thread is mainly to try and help guide the lost sheep in the right direction when it comes to PHP and building systems securely.

Now you all probably think that I'm real good at PHP but I'm not, what im good at is understanding architecture.

What i mean by architecture is summarized in these key points

  • Functional/logic view
  • Code/module view
  • Development/structural view
  • Concurrency/process/thread view
  • Physical/deployment view
  • User action/feedback view
  • Data view


From this list you will see that an application is more that an if statement here and and else statement there, its about writing code in a way that it can be used for multiple purposes and have a more abstract approach to things.

now if i refer to you as a noob do not take it personally if you write code at a lower level, theres still time to save you, but noobs are everywhere and they create sites that are error prone and unsecured and unstable.

this is why everyday somebody in this forum posts a topic regarding asome shitty php code and saying help me fix it, as you notice us programmers such as jayfella hyperz and me get annoyed because its hard to fix a peice of code thats written poorly.

so firstly im going to explain how a noob would create a small website and how it can be dramatically changed to a more stable and less error prone system.

----

Site Name: My Mini Blog
Site Desc: Small blog
Created By: A Noob

the noob would firstly start placing all his html into into index.php with some sample posts in there aswell, so he can see where he wants his code.

then after he has the design how he wants it it will cut out the html posts and place some php tags there, connect to the database and start running queries

then he will create another page call addpost.php and do the exact same as in the first page

not this is not smart atall, this means that if he wants to make a change to lets say the database he would have to go throughout each file and do lots of edits.

ok so lets talk about how a professional programmer would accomplish the same thing!

he would create a set of files that store configurations such as datbase credentials, error settings, security, options etc.

he would then create a small database layer,security layer,error layer, etc etc

this would give him the flexibility to make 1 change to his database layer and that would change for the whole application.

For example

PHP Code: 
class MySql extends mysqli
{
    public function 
__construct($host,$user,$pass,$db)
    {
         
parent::__construct($host,$user,$pass,$db);
    }

now that to me is perfect for a database start, as its extedning mysql, you instantly have a full database class based on mysql!

ok so lets say that you want to have a prefic for your tables so you can do

Code: 
SELECT * FROM #__users WHERE userid = 1
so that #__ gets turned into your prefix, well you can just create the same function thats in mysqli and work on the values before hand

PHP Code: 
public function query($query$result_mode MYSQLI_STORE_RESULT)
{
     
$querystr_replace("#__","myPrefix_",$query);
     return 
parent::query($query,$result_mode);

Now im not saying that you understand all the php functions because theres a hell of a lot im still learning, but my point is that don't be afraid to work solely with PHP to develop a stable system for your site to run on!

if you have any questions about building a system like this and how to start it, just ask your questions and ill try and help

also do not be afraid of making mistakes, if you kept doing the way you know is wrong but it works, then you will never ever learn.
litewarez Reviewed by litewarez on . [PHP] Discussion (System Building) This thread is mainly to try and help guide the lost sheep in the right direction when it comes to PHP and building systems securely. Now you all probably think that I'm real good at PHP but I'm not, what im good at is understanding architecture. What i mean by architecture is summarized in these key points Functional/logic view Code/module view Development/structural view Rating: 5