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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.