Hi all, I was just wandering about best way to place all php files in your directories, since I put all files (settings/registration/login/db-connection/index.php ... ) together in the root except the style.css ( which is in ' css/style.css ' ). Anyway, is this practice vulnerable to hacks? Or do people just create different folders to make their site feel neat or is it for another reason? I would love your intake on this. thanks
Nothing wrong with it.. but it's good practice to have a folder where all public files are (index.php, style.css, etc), and a private folder where sources/files no need for public to access. Also, make sure your permissions are set properly.
Folders are used simply for neatness oh and sometimes so that permissions can be set but if you have a properly configured server and dont leave your folders open to 777 then you can put your files where ever you want, putting them in appropiate folders help you organise your website better.
This might work for a very simple php app, but for complex ones, it is a really bad idea. Not only is the organization very poor, but it can really complicate things when trying to include file, or in the event that files have the same names or have classes with the same names. It's hard to answer specifically on your usage, but I would always segment files in at least a logical organization based on functionality. If you ever move up into framework development, it is a good idea to get used to separating files. In most MVC usage, all of the files will be in the appropriate directories under root, and none except an index and debugging and testing files will be publicly accessible in the home directory.