PHP dosyası dışında doc kök ve dışında belge kök içindeki dosyaları ihtiyacı

0 Cevap

Ben sınıfları, hepsi birbiriyle bir kütüphanesi var.

Bazı dosyalar belge kök içerde ve dışarıda bazı <Directory> and Alias httpd.conf özellikleri kullanıyor

Ben 3 dosya var varsayarsak:

webroot.php (Inside the document root)
alias_directory.php (Inside a folder outside the doc root)
alias_directory2.php (Inside a **different** folder outside the doc root)

If alias_directory2.php needs both webroot.php and alias_directory.php, This does not work. (Remember alias_directory.php and alias_directory2.php are not in the same locations)

require_once $_SERVER['DOCUMENT_ROOT'].'/webroot.php'; //(ok)
require_once $_SERVER['DOCUMENT_ROOT'].'/alias_directory.php'; //(not ok)

Alias_directory.php doc kök olmadığı için bu işe yaramaz.

Aynı

require_once $_SERVER['DOCUMENT_ROOT'].'/webroot.php'; //(ok)
require_once dirname(__FILE__).'/alias_directory.php'; //(not ok)

Burada sorun alias_directory2.php alias_directory.php olmadığı için dirname(__FILE__) yolunu dönmek olacaktır.

Bu çalışır:

require_once $_SERVER['DOCUMENT_ROOT'].'/webroot.php'; //(ok)
require_once '/full/path/to/directory/alias_directory.php'; //(ok)

Ama çok kötü ve ben başka bir yere benim kütüphane taşımak için karar verirseniz bir bakım kabus.

Bu sorunu nasıl çözerim, ben düzgün bir Alias ​​klasörü çözmek için bir yol gerekir gibi görünüyor.

0 Cevap