Jump to content

Central config file for the script


dpacmittal

Recommended Posts

I am making my own script and I want to know a way to make a central config file.

 

My directory structure was like this:

/var/www/newscript/
	           includes.php
	           index.php
	           login.php
	           logout.php
	           register.php
/var/www/newscript/
	           includes/
	           		db.php
	           		formvalidation.php
	           		common.php
	           		etc.

Now, includes.php is as such:

include('includes/db.php');
include('includes/common.php');
include('includes/security.php');
include('includes/formvalidation.php');
include('includes/forms.php');
include('includes/Email.php');

 

I just included includes.php to include all those files at once. It was working great until I moved into another directory.

I made a new directory named 'mypanel' inside 'newscript'. Now whenever I used that include file, the directory structure would mess everything up.

 

I made a central config.php for all the configuration of site. I gave the full path inside it :

$config['path'] = '/var/www/newscript/';

 

But the problem is that I can't even include config.php from different directories. I don't want to hard code config details into includes.php nor do I want to use database to get full path. Is there any way to get the full path of the /var/www/newscript/index.php using php?

Link to comment
https://forums.phpfreaks.com/topic/185222-central-config-file-for-the-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.