views:

678

answers:

2

I just started working on a site that has been passed down to me that isn't working. I've found that there's a problem when in /admin/index.php it tries to instantiate an instance of /classes/admin.php. However, if I copy /admin/index.php to /admin-index.php, it can instantiate the class just fine. Also, if I move /classes/admin.php into /admin/classes/admin.php, I can also instantiate it just fine. There is at least one other class that I've noticed this with.

I've also noticed that this isn't a problem on my local development machine. It's only an issue on the server.

You can find info about the server at http://charlesekublyfoundation.org/admin/phpinfo.php. My development machine is a WinXP machine running Apache 2.2 and PHP 5.2.11 (Apache/2.2.14 (Win32) PHP/5.2.11 ).

Has anyone seen anything like this? It seems odd. I'm fairly new to PHP development (primarily .NET developer), so I'm not sure what would cause this. I'm not sure if it's a difference in PHP or Apache or something else.

EDIT I should note that my server is running on some brand of Linux while by dev machine is Windows. I'm having a feeling that has something to do with this after looking into include_paths.

+2  A: 

There's a couple of things I can think of that might have a hand in this problem.

The most likely one I think from your description is that the developer was relying on PHP's include_path setting. This setting works with the require() and include() commands to tell them where to look for the requested file in the event that a hard path is not provided. If the code is using relative paths, and the include_path settings are different, it could be a problem. Generally the include_path will contain the "current directory" (ie, .) as part of the path, and includes are done using that as a base.

Another possibility is that the application is utilizing autoloading, and somehow this isn't translating properly to production. I'd do a quick search through the application and see if there's an __autoload() function specified, or spl_autoload_register() is used. If they are, perhaps the auto-loading function is making directory assumptions that are only true on the development machine?

zombat
The includes are using relative paths (include_once("../classes/admin.php");). I've found that it's not loading any of the other includes as well, so it likely seems like a path issue.I've tried specifying the full path on the production server (i.e. include_once("SYS:/path/to/root/classes/admin.php");), but it's still not working.The include path (from get_include_path) is ".;sys:/php5/includes".I did not find any references to autoload at all throughout the code.
jwynveen
A: 

You should examine the include paths to see why it's not working properly. The include path information will be located in your PHP configuration file (typically php.ini) as well as in the application itself. In the application you can try using the function get_include_path and print out what it returns.

Andrew Sledge
Neither of the php.ini files have include_paths specified. When I print out get_include_path on the server, it shows ".;sys:/php5/includes".
jwynveen