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