|
From: Justin F. <je...@ey...> - 2001-06-30 13:37:16
|
Alex:
Your import() is broken in any case. You sent a dot when
you should have sent a man.
If I, for debugging purposes, change prepend.php as:
function import($_file) {
global $sImportMap;
if ($sImportMap[$_file]) { return true; }
global $gImportPaths;
// at some point we should extend this to enable a list of
import paths
$gImportPaths = array(BC_PATH);
$path = strtr($_file, '.', '/') . '.php';
foreach ($gImportPaths as $prefix) {
printf("INCLUDED: %s<br>","$prefix/$path"); //<=== DEBUG
if (include_once("$prefix/$path")) {
$sImportMap[$_file] = true;
return true;
}
}
return false;
}
And then in the top of index.php, put these lines:
import('../../../bullshit');
exit;
the result is:
------------------------------------------
INCLUDED: /usr/local/binarycloud/build/en//////////bullshit.php
Warning: Failed opening
'/usr/local/binarycloud/build/en//////////bullshit.php' for inclusion
(include_path='.:/usr/share/php') in ./prepend.php on line 34
------------------------------------------------
Now Alex, you don't want THAT, do you? You are not going to
force policy of NEVER using relative directories, are you?
Of course not, I hope.
OK, I am not afraid of being laughed at for thinking out loud,
so I have been thinking about "what you want to do" with this
"package" idea, and the conventions you need to use for this,
and how import() can be smarter.
If import() is supposed to handle the abstraction of working
for importing files, and/or "packages", and/or certain files
from certain packages, ya gotta give import() more information.
I think you should think about trying something like:
import($_arg,$package=null)
and then, cumbersome as it first appears, have the calling
syntax require, if it is an "abstraction" from a package,
call it thus:
import("something_that_is_a_standalone_file")
for a true file, and:
import("something_related_to_package","package_name")
for a "file" that is in the abstraction "package_name".
You would have enough information available to import() to then
be able to parse things and come out with the ultimate correct
file to include_once().
You might even wish to establish another global map to have
tuples of "package" and "filename" held. I don't know where
you are going to go with those maps, I _do_ see their utility
and efficiency of cutting down on useless calls to PHP that
you know in advance are going to fail and burn up CPU time.
This is _only_ a quickie suggestion. I have no inkling if this
would fit in with your ideas.
Regards,
--
Justin Farnsworth
Eye Integrated Communications
321 South Evans - Suite 203
Greenville, NC 27858 | Tel: (252) 353-0722
|