On 19.11.2024 at 03:33, John D'Orazio wrote:
> […] I even recently discovered the great
> feature that was introduced in PHP 7.4 `PHP_CLI_SERVER_WORKERS`, which I sorely
> needed because my API makes a couple of requests internally to various paths of
> the API, and nested requests require more than one process / worker, which
> wasn't a problem for the Nginx / Apache production server but would have been a
> problem on localhost using the built-in server if it weren't for this
> environment variable.
>
> Seeing I have a number of people interested in contributing to the project, they
> have been asking me how they can develop on localhost without the trouble of
> setting up a whole WAMP environment. […]
I don't quite understand how WAMP fits into this. WAMP is Windows only,
and on Windows `PHP_CLI_SERVER_WORKERS` is not supported.
> In my use case, I have an API backend that I can spin up with `php -S
> localhost:8000`. Then when I spin up the frontend (which is also written in
> PHP), it knows nothing about where to find the API backend. On the production
> server, I had the host hardcoded into the frontend application. But if I want to
> be able to dynamically switch between localhost and production, I need to be
> able to instruct the frontend of where to find the API backend. This can easily
> be achieved through dotenv files, and even better if we have an automatic
> environment variable of `$_ENV[APP_ENV]=development`. I see that there is a
> composer package (https://github.com/vlucas/phpdotenv) that can achieve loading
> dotenv files, but other than loading dotenv files by means of a composer package
> it would be nice if we could at least have an automatic environment variable of
> `$_ENV[APP_ENV]=development` created by PHP's built-in server. Seeing that the
> built-in server will pretty much always be used for easy localhost development,
> I don't see any reason why a `development` environment variable couldn't or
> shouldn't be created by the built-in server? It would make PHP localhost
> development that much more user friendly in my opinion...
Besides that setting an environment globally is not necessarily
possible, this looks somewhat backwards to me, and is in my opinon way
too special – why would only the built-in development server advertize
itself as a development environment?
Christoph
Sorry for the typo, I meant to write 'LAMP'. I have always setup a Linux Apache MySQL PHP environment for local development. But I find that not everyone is so keen on such an involved local setup. Which is why I find the built-in server such a great convenience. It greatly simplifies the development process. Do my two cents are simply, why not take it one more step and make an environment similar / familiar to other development environments?
On Nov 19, 2024 1:12 PM, "Christoph M. Becker" <cmbecke...@gmx.de> wrote:
- [PHP-DEV] Better development streamlining of the bui... John D'Orazio
- Re: [PHP-DEV] Better development streamlining o... Christoph M. Becker
- Re: [PHP-DEV] Better development streamlini... John D'Orazio
- Re: [PHP-DEV] Better development streamlining o... Bruce Weirdan
- Re: [PHP-DEV] Better development streamlini... John D'Orazio
- Re: [PHP-DEV] Better development stream... Bilge
- Re: [PHP-DEV] Better development st... John D'Orazio
- Re: [PHP-DEV] Better developme... Bilge
- Re: [PHP-DEV] Better devel... Hammed Ajao
- Re: [PHP-DEV] Better d... Rowan Tommins [IMSoP]
- Re: [PHP-DEV] Better d... Bilge