views:

67

answers:

2

I've created a php file called pagebase.php that I'm quite proud of. It contains a class that created the whole html file for me from input such as css links and js links. In any case, this file is several hundred lines long, as it includes several helper functions such as cleanHTML() that removes all whitespace from the html code then, in layman's terms, makes the source look pritty.

I have decided to use this pagebase in all my projects, particularly in all my internal projects. I also plan to add and expand to the pagebase file quite a lot. So what I'm wondering is if it's possible to set the allow_url_include option to on, but just on this one single file.

If I got my theory right, that would allow me to include() that file from any server and get the pagebase class.

Thanks for all answers!

+1  A: 

That is a bad practice.
You should put this file along with the project that needs it and locally include() it.

shamittomar
Not what i asked
Codemonkey
+4  A: 

So what I'm wondering is if it's possible to set the allow_url_include option to on, but just on this one single file.

No, as far as I'm aware this is not possible.

What you are planning to do sounds like a bad idea anyway, though. An include that gets loaded over the web on every request is awful for performance.

You should keep local copies of your library, and use a update script (or version control system) to keep versions up to date.

Pekka
Would writing a php script that updated the pagebase.php file using ftp be possible?
Codemonkey
@Codemonkey sure, absolutely. That sounds like a good idea.
Pekka
@Codemonkey: Or use an existing system like e.g. pear/pyrus, see http://pear.php.net/manual/en/channels.scs.intro.php
VolkerK
The problem is that I'm using the pagebase in 5 projects simultaneously, and I like to add functions and such as I work on each individual project. That's where the shared source would come in handy.But seeing as you've informed me that it can't be done in a safe manner, could you tell me how I can set up a PHP script to run at an interval without any external instruction to do so?
Codemonkey
@Codemonkey wouldn't it be more feasible to actively update the individual projects from one central location once you've finished a change?
Pekka
I didn't consider that one script could actively place the new file at a list of locations. I was thinking i had to put the script on each of the locations to fetch the updated file.Thanks for the idea :P I'll look into it
Codemonkey
@Codemonkey you're welcome, but be careful. There is no easier way to shoot down production sites than updating them with new libraries without testing. :D
Pekka