Directory structure management for PHP script

kjyiwt8sey

New Member
I'm writing a profile-based image downloader, and it's structured in multiple files:\[code\]lib/profiles/getbooruinstallreadmeuninstall\[/code\]If I include these files like this:\[code\]include 'lib/curl';include 'lib/string';foreach(glob('profiles/*') as $profile) include $profile;\[/code\]The program only works if you call it from the program's directory. If I change it to this:\[code\]set_include_path('/usr/local/share/getbooru');include 'lib/curl';include 'lib/string';foreach(glob('/usr/local/share/getbooru/profiles/*') as $profile) include $profile;\[/code\]Then it forces the users to run an install script to put the files in that directory, and it won't work anywhere else. In this case, \[code\]getbooru\[/code\] is symlinked to \[code\]/usr/local/bin/getbooru\[/code\].Good news: I noticed that if I try to get the filename of the running script, even if it's running through a symlink, it'll always return the 'real' script name (so that I don't include nonexistent stuff from \[code\]/usr/local/bin\[/code\]).How can I make this program portable to run anywhere?
 
Back
Top