Re: PHP vs Apache

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11.07.2022 at 21:02, paulf@xxxxxxxxxxxxxxxxx wrote:

> I have two PHP apps on the same (local) box. One handles financial
> transactions (A) and the other handles budgeting (B). I want B to query
> A for information for the budget. So I'm technically querying a remote
> PHP script from within a different "site" and PHP script on the same
> box. Like this:
>
> http://localhost:8000/budget/get_expenses.php queries
> http://localhost:8000/finance/expenses.php
>
> I hope that makes sense. I have "allow_url_fopen = On" in my php.ini.
> There are three ways I've seen to do this:
>
> file_get_contents()
> fopen()
> curl*
>
> Curl is complex, so I haven't tried it yet.
> I've tried file_get_contents() via the PHP development server. Doesn't
> work. Generates an error.
> I've tried fopen() on the PHP development server, but it too fails with
> the same error. The error looks like this:
>
> [Mon Jul 11 14:45:26 2022] PHP Warning:
> fopen(http://localhost:8000/slowen/index.php): Failed to open stream:
> HTTP request failed! in /home/paulf/public_html/budget/test.php on line
> 7
>
> The call to the "remote" script is on line 7 in test.php above.
>
> Here's the wrinkle: fopen() works if I'm using the Apache server.
>
> For what it's worth, the script being queried should return a PHP array
> in JSON format. The box is an Arch current box.
>
> Can anyone explain why Apache can do this, but PHP's dev server can't?

>From the docs[1]:

| The web server runs only one single-threaded process, so PHP
| applications will stall if a request is blocked.

I assume that this is the problem.  If it is, you can work around:

| You can configure the built-in webserver to fork multiple workers in
| order to test code that requires multiple concurrent requests to the
| built-in webserver. Set the PHP_CLI_SERVER_WORKERS environment
| variable to the number of desired workers before starting the server.
| This is not supported on Windows.

[1] <https://www.php.net/manual/en/features.commandline.webserver.php>

--
Christoph M. Becker




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux