Wednesday, 8 August 2007

PHP and the require_once() function to name one issue

I have been battling for a number of months to try and get WebPA into a state so that it will work when installed on any platform. My first steps have been to try and remove all of the $_SERVER['DOCUMENT_ROOT'] references and replace them with relative links. I wanted everything to be linked relatively as you can then take a web application from one server and place it on to another with out having to go through all of the code to make it work. Yes I know that PHPites like to use the inbuilt server variables where possible, which can be good, but in the case of porting an application to a Microsoft based architecture will cause all kind of problems.

Once I changed all of the code to relative links, everything began to go wrong. But it appears that it is not just going wrong for me, this appears to be a common problem with PHP. If you do a Google search you will come up with a plethora of similar postings where people are suffering similar problems. At the moment I am trying to find a solution to the problem. I need to locate a work around that will suffice as WebPA needs to be easy to install, even by some one with little to no technical knowledge. My solution has been to user ‘./’ (dot forward-slash) to take me directly to the application root, load the global include file on its path and then, as others do, define my own DOC__ROOT. But am I there am I hell.

Although I get the login page on a WAMP and also on the MAMP set-ups, when I try to login then I get the same error message. However, when I run everything on a LAMP set-up, I get a completely different error all together. Well saying that all the errors are all related again to the require_once function in PHP.

Eventully I found the solution thanks to the folks who post fixes on the php manual pages. It isn't the most elegent of solutions, but it works. As of today I can say WebPA will work on all configurations that I can think of.

No comments: