NYCPHP Meetup

NYPHP.org

[nycphp-talk] Where do name spaces come from?

Adam Maccabee Trachtenberg adam at trachtenberg.com
Tue Mar 30 01:17:10 EST 2004


On Tue, 30 Mar 2004, Faber Fedor wrote:

> What's confusing me is the "server." notation.  I haven't seen a guide
> on where that comes from (why "server" in this example and not "foo"?).

XML-RPC was written by Dave Winer. Dave also wrote a system called
Frontier. Frontier used the "." as a namespace / path
separator. (Frontier is a weird hybrid scripting language / object
database system that's now been extended to include a web server and
more. It's hard to explain if you've never seen it.) So, what in PHP
is mysql_query() would be mysql.query() in Frontier.

>From this background I conclude that when Dave wrote up the original
XML-RPC examples, he just used Frontier notation and everybody else
copied it blindly.

> Is it the file name?  If so, why did changing the file name to
> "my_server.php" and renaming the name space appropriately not work?  Is
> it some sort of internally defined name (although I couldn't find it in
> the file)?

I don't think it has to be anything. See this quotation from the spec
(http://www.xml-rpc.com/spec):

> The payload is in XML, a single <methodCall> structure.
>
> The <methodCall> must contain a <methodName> sub-item, a string,
> containing the name of the method to be called. The string may only
> contain identifier characters, upper and lower-case A-Z, the numeric
> characters, 0-9, underscore, dot, colon and slash. It's entirely up
> to the server to decide how to interpret the characters in a
> methodName.
>
> For example, the methodName could be the name of a file containing a
> script that executes on an incoming request. It could be the name of
> a cell in a database table. Or it could be a path to a file
> contained within a hierarchy of folders and files.

As you can see, it's entirely up to you how to choose what naming
convention you wish to use.

The easiest thing, given that PHP lacks namespaces, is to omit the
period completely and just have the value stored in the <methodName>
be the name of your PHP function. Or not. :)

-adam

-- 
adam at trachtenberg.com
author of o'reilly's php cookbook
avoid the holiday rush, buy your copy today!



More information about the talk mailing list