views:

40

answers:

1

Let me put my issue defining a real scenario:

I am using dedicated server where PHP and MySQL are available. My PHP include_path=/var/local/php

I am developing a custom cms application, where I am writing my own library which is responsible for communicating with the database and retrieving data based on some key.

My application is going to be used by many customers so, when their account is created, my application will generate a key and they will create web pages for some of other functions like news, events, gallery etc. So I am creating folder for them; it has all the files uploaded as well as generated PHP files for them.

So currently, created files need database setting as well as use my custom library classes (which has all database communication, so when they click on news menu, automatically I want to allow them to use my database setting without exposing it to them directly).

In short, I am creating PHP files for them (which does not have many database setting references, so based on the key I want to return data), as they are on same server.

Example:

  • domain1.com located at /home/domain1.com
  • domain2.com located at /home/domain2.com

So each domain has my PHP files created as per the functionality, but right now, I am in trouble to get access to my custom library. Eventually, I am specifying them in php.ini.

I hope my scenario is clear. Please help me on this.

Goal: Allow each domain to access my custom library like PEAR etc. so rest of thing will be work as it is expected.

A: 

You have 2 options

  1. Add the path you need to include to your include_path and use relative paths like require "lib/class.php"

  2. Use absolute paths: require "/home/common/lib/class.php"

michal kralik