[PHP-DEV] [emile@iris-advies.com: Re: [PHP-DEV] Adding URI Translation Handlers]

2001-06-22 Thread Stephen van Egmond

Back when the mailing lists were down, I started a discussion about
adding a feature to PHP to do URI translating.

The brief definition of URI translation is that you get to rewrite URIs
dynamically.  This is how you you would host, for instance, 10,000
florist home pages:

http://florists.ftd.com/rosebowlfloral/
and http://florists.ftd.com/fiveflower/

without having 10,000 directoriies under the server root.  In Apache,
these would be rewritten to a directory containing the style of page
the florist chose, with some extra apache notes to tell you which
florist page had been visited.

The question I wanted to raise was how to do this.  And although it
looks like initially a simple task, it generalizes to a few other
concepts which Apache + mod_perl has done wonders with.

This was the most recent post on the topic, and I wondered if there
were other thoughts out there?

Failing that, I will probably pursue the approach of building this into
the Apache SAPI and letting other web servers follow suit.


- Forwarded message from Emiliano [EMAIL PROTECTED] -

Date: Thu, 31 May 2001 09:34:00 +0200 (CEST)
From: Emiliano [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DEV] Adding URI Translation Handlers

Stephen van Egmond wrote:

 One thing which I am bumping into is the need to do URI rewriting, kind
 of like what mod_perl does.
 
 I would like to implement this myself in mod_php, and I'm looking for
 some advice on the implementation.  I considered the following:
 
 a) Allowing the automatically prepended file (see php's
 auto_prepend_file config option) to change $ENV['REQUEST_URI'] before
 the script is actually executed. This, intuitively, seems clean, but
 would probably happen too late in the request process (it will have
 already decided to call the error file).

Yep. This would be executed in the response phase, but apache itself
would have decided in the translation phase way before that not to
handle the request.

 b) adding a new config directive that... what?  defines a file to be
 read which is supposed to define a function? Is eval'ed?

The way I see it you have a couple of options:

- Use mod_perl, mod_python, mod_tcl(I think) to script a translation
  handler.
- Write a translation handler in C (we do this with Midgard)
- Extend mod_php4 to do what mod_perl et al do so you can write
  handlers in PHP. Conceptually, this is not too hard, but will
  definately be more work than the other two. You set up the zend
  engine just like the response phase handler does, set a few relevant
  variables before you start it (like $ENV['REQUEST_URI'] for example,
  kick off the script (either be just executing the code, or calling a
  function therein), then read the relevant variables after the script
  exits and act on them. You'll be doing this in C.

Emile


- End forwarded message -

-- 
   ,,,
  (. .)
+--ooO-(_)-Ooo- -  -- - - -  -
| The Annotated BeBook:  http://bang.dhs.org/be/bebook/

-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] [emile@iris-advies.com: Re: [PHP-DEV] Adding URI Translation Handlers]

2001-06-22 Thread Brian Moon

Isn't this what mod_rewrite is for?

Also, what we do is have urls like:

http://dealnews.com/articles/23930.html

We use a force type on the feil articles to make it get parsed as PHP.  We
then read $PATH_INFO in which is /23930.html to set up our vars.

You could have:

http://florists.ftd.com/florists/rosebowlfloral/

Although it makes for a longer URL, it does not require all the files you
talked about and does not require any C.

Brian Moon
--
dealnews.com, Inc.
Makers of dealnews  dealmac
http://dealnews.com/ | http://dealmac.com/


- Original Message -
From: Stephen van Egmond [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, June 22, 2001 12:09 AM
Subject: [PHP-DEV] [[EMAIL PROTECTED]: Re: [PHP-DEV] Adding URI
Translation Handlers]


 Back when the mailing lists were down, I started a discussion about
 adding a feature to PHP to do URI translating.

 The brief definition of URI translation is that you get to rewrite URIs
 dynamically.  This is how you you would host, for instance, 10,000
 florist home pages:

 http://florists.ftd.com/rosebowlfloral/
 and http://florists.ftd.com/fiveflower/

 without having 10,000 directoriies under the server root.  In Apache,
 these would be rewritten to a directory containing the style of page
 the florist chose, with some extra apache notes to tell you which
 florist page had been visited.

 The question I wanted to raise was how to do this.  And although it
 looks like initially a simple task, it generalizes to a few other
 concepts which Apache + mod_perl has done wonders with.

 This was the most recent post on the topic, and I wondered if there
 were other thoughts out there?

 Failing that, I will probably pursue the approach of building this into
 the Apache SAPI and letting other web servers follow suit.


 - Forwarded message from Emiliano [EMAIL PROTECTED] -

 Date: Thu, 31 May 2001 09:34:00 +0200 (CEST)
 From: Emiliano [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 cc: [EMAIL PROTECTED]
 Subject: Re: [PHP-DEV] Adding URI Translation Handlers

 Stephen van Egmond wrote:

  One thing which I am bumping into is the need to do URI rewriting, kind
  of like what mod_perl does.
 
  I would like to implement this myself in mod_php, and I'm looking for
  some advice on the implementation.  I considered the following:
 
  a) Allowing the automatically prepended file (see php's
  auto_prepend_file config option) to change $ENV['REQUEST_URI'] before
  the script is actually executed. This, intuitively, seems clean, but
  would probably happen too late in the request process (it will have
  already decided to call the error file).

 Yep. This would be executed in the response phase, but apache itself
 would have decided in the translation phase way before that not to
 handle the request.

  b) adding a new config directive that... what?  defines a file to be
  read which is supposed to define a function? Is eval'ed?

 The way I see it you have a couple of options:

 - Use mod_perl, mod_python, mod_tcl(I think) to script a translation
   handler.
 - Write a translation handler in C (we do this with Midgard)
 - Extend mod_php4 to do what mod_perl et al do so you can write
   handlers in PHP. Conceptually, this is not too hard, but will
   definately be more work than the other two. You set up the zend
   engine just like the response phase handler does, set a few relevant
   variables before you start it (like $ENV['REQUEST_URI'] for example,
   kick off the script (either be just executing the code, or calling a
   function therein), then read the relevant variables after the script
   exits and act on them. You'll be doing this in C.

 Emile


 - End forwarded message -

 --
,,,
   (. .)
 +--ooO-(_)-Ooo- -  -- - - -  -
 | The Annotated BeBook:  http://bang.dhs.org/be/bebook/

 --
 PHP Development Mailing List http://www.php.net/
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]





-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] Adding URI Translation Handlers

2001-06-22 Thread Brian Moon

Now as for precompiled code, I am all for that.  We have lots of bit of code
that are run on every page and I know that it is possible to rework all this
somehow to not have to do that.

I am still not clear on your problem with the rewriting.  I don't see what
the number of files in the templates has to do with anything.

Can you elaborate more on that.  Maybe some examples of what the request
would be and how you would rewrite it and why.

Brian Moon
--
dealnews.com, Inc.
Makers of dealnews  dealmac
http://dealnews.com/ | http://dealmac.com/


- Original Message -
From: Stephen van Egmond [EMAIL PROTECTED]
To: Brian Moon [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Friday, June 22, 2001 12:50 PM
Subject: Re: [PHP-DEV] Adding URI Translation Handlers


 Brian Moon ([EMAIL PROTECTED]) wrote:
  Isn't this what mod_rewrite is for?

 mod_rewrite works only in a static sense.  You set up your rules, and
 fire up your Apache.  If your rules change (as they certainly will in
 the case of 10,000 florists), you have to rewrite the rules file and
 restart apache.

  http://florists.ftd.com/florists/rosebowlfloral/

 It also doesn't address the issue of the various files which will be
 there. Path_info will work with one file, in the case of articles.

 But if each (in this case) florist has a series of files in their
 templates (product detail pages, personal accounts, ordering pages,
 etc) you're out of luck.

 The example is real; I was the lead developer for florists.ftd.com for
 most of last year.

 The point I'm making is that I would like to improve the Apache SAPI
 code for PHP to support more of the Apache server's features, like the
 request rewriting step, tear-up/tear-down, and even precompiling code
 when the server forks so that it doesn't need to be recomputed on every
 hit.

 Are there other people interested in this that would like to get a
 hacking crew together?





-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DEV] Adding URI Translation Handlers

2001-06-22 Thread Stephen van Egmond

Brian Moon ([EMAIL PROTECTED]) wrote:
 I am still not clear on your problem with the rewriting.  I don't see what
 the number of files in the templates has to do with anything.
 
 Can you elaborate more on that.  Maybe some examples of what the request
 would be and how you would rewrite it and why.

Consider, for example, sourceforge.

http://sourceforge.net/projects/myproject/index.html
http://sourceforge.net/projects/myproject/bug-list.html
http://sourceforge.net/projects/myproject/bug-add.html

There are zillions of myprojects, with new ones coming on at the rate
of at least several per day.

These are all pages which, in the URI - filename translation step of
Apache, need to get pointed at some canonical project template
directory.

Doing this with one rewrite, as you did with articles and pathinfo,
doesn't seem sufficient, since there are in fact several files under
each directory rather than just one.

/articles/65902.html
probably gets rewritten to
/articles.php

which has to go looking through pathinfo. Fine, it works.  But I don't
think pathinfo is up to the task above.


-- 
PHP Development Mailing List http://www.php.net/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]