
So an approach of defining path constants may look like: define('WEB_ROOT', $_SERVER) ĭefine('INCLUDE_DIR', ) ĭefine('CONFIG_DIR', INCLUDE_DIR. You may be able to count on this behavior for some specific shared host environment, but this gives you no guarantee that this same behavior would exist in another environment. Typically, this is done by configuring constants for file paths in a config file, not by relying on values derived from $_SERVER as this has absolutely no connection to where on a server you may have the ability to place your non-public application code.
#Php include file code
So ideally, your application should be able to seamlessly handle both without custom code that changes based on where you deploy the application.

#Php include file full
Or, if you had full control over your environment it might look like: /some/nonpublic/directory => non-public directory (possibly in include path) path/to/your/directory/public => the web server document root I am assuming that you have a directory structure something like this, which can be common in shared hosting environments: /path/to/your/directory => your customer directory on the host My question is: Is this a good idea, or sloppy? Is $_SERVER reliable enough that, should I deploy this on a dedicated server in the future, it will still work? The theory is that I make sure the 'configs' folder is just above DOCUMENT_ROOT, grab all but the last part of the DOCUMENT_ROOT path, and the PHP script should be able to find the config file stored there. However, for the purposes of demonstration I'm deploying this database and front end on a shared server which will not give me access to nf.

ini file so that PHP could access it and then parse the config file. I WAS setting an environment variable in nf to the file path of the. In order to keep that information secure, I'm storing it outside of the web root on the server. To further complicate things, when a user navigates to the Joomla website, the index.php of the root directory redirects to the index.php of the current template.To enable my PHP scripts to access my MySQL database, I have a configuration file containing the name of the MySQL database, usernames, etc.

Thus when a user navigates to the web server delivers Because Joomla! is written in PHP, index.php is the automatically-served file.
It also shows the value of the DIR constant:Home

Where index.php differs is the use of PHP code to insert information selected from a database.īaseurl ?>templates/mytemplate/css/css.css" type="text/css" /> The code will be familiar to anyone who has designed a simple HTML web page. The index.php file for a template contains a mixture of code that will be delivered as it is, and PHP code that will be modified before it is delivered. Every page that Joomla! delivers is index.php fleshed out with content inserted from the database. The index.php file is the skeleton of the website.
