Re: [PHP] How to run one php app from another?

2006-08-13 Thread Gerry D

I don't know if you solved this already, but I use it to redirect to
different pages depending on whther the user is logged in or not.

Something like header(location:/page/?p=login); works fine. You were
on the right track.

Gerry

On 6/15/06, tedd [EMAIL PROTECTED] wrote:

Hi gang:

This seems like so obvious a question, I am reluctant to ask.

In any event, I simply want my php application to run another, like so:

switch (option)
   {
   case a:
   run a.php;
   exit;
   break;

   case b:
   run b.php;
   exit;
   break;

   case c:
   run c.php;
   exit;
   break;
  }

I know that from within an application I can run another php application via a user click 
(.e., button), or from javascript event (onclick), or even from cron. But, what if you 
want to run another application from the results of a calculation inside your main 
application without a user trigger. How do you do that?

I have tried header(Location: http://www.example.com/;); ob_start(), 
ob_flush() and such, but I can't get anything to work.

Is there a way?

Thanks.

tedd
--

http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to run one php app from another? RECAP

2006-06-19 Thread Manuel Amador (Rudd-O)
Excuse me... in which scenarios isn't fork() available?  As far as I
know, it even works on Windows (albeit slower... not that you'll be
gaining any performance by curl'ing your URL - that's actually slower
than fork()).

El vie, 16-06-2006 a las 11:25 -0300, Martin Alterisio escribió:
 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to run one php app from another? RECAP

2006-06-19 Thread Manuel Amador (Rudd-O)
El vie, 16-06-2006 a las 15:54 -0500, Richard Lynch escribió:
 On Fri, June 16, 2006 9:25 am, Martin Alterisio wrote:
  You can fork a new process a run the other script in the child
  process. But
  forking is not always available so I also use another approach:
  emulate a
  web page request through sockets or curl to the script I want to run.
 
 Forking in a web environment is a Bad Idea, as documented in the manual.

This is true.  Basically you need to ensure that the child process
exits() always, or you'll have a ton of apache processes running left
behind.  Not to mention that you should not attempt to access any of the
shared resources (yes, that includes print and echo since they share the
standard output file descriptor, and obviously database connections are
included) because you're not going to get consistent results.

 
 YMMV
 
 -- 
 Like Music?
 http://l-i-e.com/artists.htm
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to run one php app from another? RECAP

2006-06-19 Thread Chris

Manuel Amador (Rudd-O) wrote:

Excuse me... in which scenarios isn't fork() available?  As far as I
know, it even works on Windows (albeit slower... not that you'll be
gaining any performance by curl'ing your URL - that's actually slower
than fork()).


It's (probably) not that the fork() etc commands don't work on windows, 
just that the php functions don't.


http://www.php.net/pcntl

--
Postgresql  php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to run one php app from another? RECAP

2006-06-19 Thread Richard Lynch
On Mon, June 19, 2006 8:13 pm, Chris wrote:
 Manuel Amador (Rudd-O) wrote:
 Excuse me... in which scenarios isn't fork() available?  As far as I
 know, it even works on Windows (albeit slower... not that you'll be
 gaining any performance by curl'ing your URL - that's actually
 slower
 than fork()).

 It's (probably) not that the fork() etc commands don't work on
 windows,
 just that the php functions don't.

 http://www.php.net/pcntl

fork() in anything other than CLI/CGI is dangerous because PHP
extensions (and/or web-server extensions) are not known to be
thread-safe.

So, by definition, when you fork in a web-server, you are just ASKING
for an intermittent bug, that will be virtually impossible to catch
with QA and which will bite you in the ass when you are slashdotted,
i.e. at the worst possible time.

If your run a special PHP server with NOTHING loaded into it, no
mysql, no gd, no nothing, you could *MAYBE* have some reasonable
chance of it not puking all over you blue suede shoes...

But I sure wouldn't bet the company bottom line on it.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to run one php app from another? RECAP

2006-06-19 Thread Chris

Richard Lynch wrote:

On Mon, June 19, 2006 8:13 pm, Chris wrote:

Manuel Amador (Rudd-O) wrote:

Excuse me... in which scenarios isn't fork() available?  As far as I
know, it even works on Windows (albeit slower... not that you'll be
gaining any performance by curl'ing your URL - that's actually
slower
than fork()).

It's (probably) not that the fork() etc commands don't work on
windows,
just that the php functions don't.

http://www.php.net/pcntl


fork() in anything other than CLI/CGI is dangerous because PHP
extensions (and/or web-server extensions) are not known to be
thread-safe.


I'm not debating any of that, he asked why the functions don't work in 
windows, I said that the php functions don't, not necessarily that 
fork() doesn't.


--
Postgresql  php tutorials
http://www.designmagick.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] How to run one php app from another? RECAP

2006-06-16 Thread tedd
Hi gang:

So, there is NOT a way for one running php-application to call another and have 
it run while having the parent quit?

For example, program a runs and presents the user with a web page. The user 
responds in some fashion (i.e., enters text) and clicks Submit. Then the 
application analyzes the data and chooses to run application d from a list of 
possible applications. NOTE: This is different than the user clicking a link to 
run application d. It is application a that's making the choice to run d, 
not the user. Can this be done?

Let me recap the solutions offered:

1. There was the suggestion to use includes(). However, includes simply adds 
code into the current application. It does not terminate the parent nor start 
another application. It simply bloats the parent.

2. There was the suggestion to use ob_start with header(Location: ...); and 
finish with ob_flush. However, the parent application never shows itself -- the 
process simply cascades down to the end application. In this case, the parent 
(as in the example above) would never show the user the text-box to enter 
his/her text.

3. There was the suggestion to use js, which works and is the way I'm doing it 
now. However, I wanted a php solution.

So, what say you fine php people, can anyone give me an example of a php 
application running (i.e., calling) another? I suspect that php can't, but I 
don't know why -- it doesn't seem logical. Is this one of those stateless 
problematic thingies, or what?

Thanks.

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to run one php app from another? RECAP

2006-06-16 Thread Rabin Vincent

On 6/16/06, tedd [EMAIL PROTECTED] wrote:

So, what say you fine php people, can anyone give me an example of a php 
application running (i.e., calling) another?


What about something like the code below? I use an extension of
that to fake some threading/multi-processing.

echo file_get_contents('http://domain.com/other.php');
exit;

Rabin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to run one php app from another? RECAP

2006-06-16 Thread Martin Alterisio

2006/6/16, tedd [EMAIL PROTECTED]:


Hi gang:

So, there is NOT a way for one running php-application to call another and
have it run while having the parent quit?

For example, program a runs and presents the user with a web page. The
user responds in some fashion (i.e., enters text) and clicks Submit.
Then the application analyzes the data and chooses to run application d
from a list of possible applications. NOTE: This is different than the user
clicking a link to run application d. It is application a that's making
the choice to run d, not the user. Can this be done?

Let me recap the solutions offered:

1. There was the suggestion to use includes(). However, includes simply
adds code into the current application. It does not terminate the parent nor
start another application. It simply bloats the parent.

2. There was the suggestion to use ob_start with header(Location: ...);
and finish with ob_flush. However, the parent application never shows itself
-- the process simply cascades down to the end application. In this case,
the parent (as in the example above) would never show the user the text-box
to enter his/her text.

3. There was the suggestion to use js, which works and is the way I'm
doing it now. However, I wanted a php solution.

So, what say you fine php people, can anyone give me an example of a php
application running (i.e., calling) another? I suspect that php can't, but
I don't know why -- it doesn't seem logical. Is this one of those stateless
problematic thingies, or what?

Thanks.

tedd
--


http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



You can fork a new process a run the other script in the child process. But
forking is not always available so I also use another approach: emulate a
web page request through sockets or curl to the script I want to run.


Re: [PHP] How to run one php app from another? RECAP

2006-06-16 Thread Richard Lynch
On Fri, June 16, 2006 7:26 am, tedd wrote:
 So, there is NOT a way for one running php-application to call another
 and have it run while having the parent quit?

 1. There was the suggestion to use includes(). However, includes
 simply adds code into the current application. It does not terminate
 the parent nor start another application. It simply bloats the parent.

This is actually going to be the cheapest thing to do.

If there is monstrous data in the parent you could unset() it and
reduce bloat

But, really, the cost here is a hard drive seek to get the other
script, and you're going to incur that cost no matter what other
solution you use.

So this IS the cheapest way to achieve what you want.

 So, what say you fine php people, can anyone give me an example of a
 php application running (i.e., calling) another? I suspect that php
 can't, but I don't know why -- it doesn't seem logical. Is this one of
 those stateless problematic thingies, or what?

You could do an exec() and have the program being executed fork or use
 and then the parent would quit, but once the parent quits, you lose
your connection to the browser and stdout/stdin and all that for the
child.

You could also do a Location: header, but again losing all the data
from parent application, unless you pass it in URL or $_SESSION.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to run one php app from another? RECAP

2006-06-16 Thread Richard Lynch
On Fri, June 16, 2006 9:25 am, Martin Alterisio wrote:
 You can fork a new process a run the other script in the child
 process. But
 forking is not always available so I also use another approach:
 emulate a
 web page request through sockets or curl to the script I want to run.

Forking in a web environment is a Bad Idea, as documented in the manual.

YMMV

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to run one php app from another? RECAP

2006-06-16 Thread tedd
At 3:48 PM -0500 6/16/06, Richard Lynch wrote:
On Fri, June 16, 2006 7:26 am, tedd wrote:
 So, there is NOT a way for one running php-application to call another
 and have it run while having the parent quit?

 1. There was the suggestion to use includes(). However, includes
 simply adds code into the current application. It does not terminate
 the parent nor start another application. It simply bloats the parent.

This is actually going to be the cheapest thing to do.

If there is monstrous data in the parent you could unset() it and
reduce bloat

But, really, the cost here is a hard drive seek to get the other
script, and you're going to incur that cost no matter what other
solution you use.

So this IS the cheapest way to achieve what you want.

 So, what say you fine php people, can anyone give me an example of a
 php application running (i.e., calling) another? I suspect that php
 can't, but I don't know why -- it doesn't seem logical. Is this one of
 those stateless problematic thingies, or what?

You could do an exec() and have the program being executed fork or use
 and then the parent would quit, but once the parent quits, you lose
your connection to the browser and stdout/stdin and all that for the
child.

You could also do a Location: header, but again losing all the data
from parent application, unless you pass it in URL or $_SESSION.


Thanks for the additional information -- much to consider here.

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] How to run one php app from another?

2006-06-15 Thread tedd
Hi gang:

This seems like so obvious a question, I am reluctant to ask.

In any event, I simply want my php application to run another, like so:

switch (option)
   {
   case a:
   run a.php;
   exit;
   break;

   case b:
   run b.php;
   exit;
   break;

   case c:
   run c.php;
   exit;
   break;
  }

I know that from within an application I can run another php application via a 
user click (.e., button), or from javascript event (onclick), or even from 
cron. But, what if you want to run another application from the results of a 
calculation inside your main application without a user trigger. How do you 
do that?

I have tried header(Location: http://www.example.com/;); ob_start(), 
ob_flush() and such, but I can't get anything to work.

Is there a way?

Thanks.

tedd
-- 

http://sperling.com  http://ancientstones.com  http://earthstones.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] How to run one php app from another?

2006-06-15 Thread Richard Lynch


Just include 'a.php'; and it will get done.

On Thu, June 15, 2006 11:11 am, tedd wrote:
 Hi gang:

 This seems like so obvious a question, I am reluctant to ask.

 In any event, I simply want my php application to run another, like
 so:

 switch (option)
{
case a:
run a.php;
exit;
break;

case b:
run b.php;
exit;
break;

case c:
run c.php;
exit;
break;
   }

 I know that from within an application I can run another php
 application via a user click (.e., button), or from javascript event
 (onclick), or even from cron. But, what if you want to run another
 application from the results of a calculation inside your main
 application without a user trigger. How do you do that?

 I have tried header(Location: http://www.example.com/;); ob_start(),
 ob_flush() and such, but I can't get anything to work.

 Is there a way?

 Thanks.

 tedd
 --
 
 http://sperling.com  http://ancientstones.com  http://earthstones.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php