Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symfony tool --port flag does not set port to access the website by the browser when used with php-cli #343

Open
flip111 opened this issue Sep 14, 2023 · 9 comments

Comments

@flip111
Copy link

flip111 commented Sep 14, 2023

» symfony server:start --no-tls --port=45431
Following Web Server log file (/home/flip111/.symfony5/log/e2c76d1e80d5e2314378f4c21b372bc1d048d92e.log)
Following PHP log file (/home/flip111/.symfony5/log/e2c76d1e80d5e2314378f4c21b372bc1d048d92e/7daf403c7589f4927632ed3b6af762a992f09b78.log)

 [WARNING] The local web server is optimized for local development and MUST never be used in a production setup.

 [OK] Web server listening
      The Web server is using PHP CLI 8.2.10
      http://127.0.0.1:45431

[Web Server ] Sep 14 14:33:46 |DEBUG  | PHP    Reloading PHP versions
[Web Server ] Sep 14 14:33:47 |DEBUG  | PHP    Using PHP version 8.2.10 (from default version in $PATH)
[Web Server ] Sep 14 14:33:47 |INFO   | PHP    listening path="/usr/bin/php8.2" php="8.2.10" port=45443
[PHP        ] [Thu Sep 14 14:33:47 2023] PHP 8.2.10 Development Server (http://127.0.0.1:45443) started

Notice that server says [OK] Web server listening with address http://127.0.0.1:45431 but then on the last line PHP development server says it started on another address http://127.0.0.1:45443. The latter is the actual address the server was hosted on

A technical explanation was given by @stof that under the hood two servers are used (one proxy server)

code -> symfony proxy -> php webserver -> browser

What would be cool is that instead of "find available port" you could configure the actual port you have to connect to with the browser.

port, err := process.FindAvailablePort()

@tucksaun
Copy link
Contributor

You can (and should) use the first port displayed (45431) which does match the one you asked for.

The fact that the PHP web-server is used under the hood and runs on port 45443 is not stable.
For example if for any reason you now get PHP-FPM available, the CLI will automatically switch to FPM which is not reachable directly by the browser.
This is (one of the reasons) why the CLI exposes an HTTP port that is the one you should use.

@stof
Copy link

stof commented Sep 15, 2023

@flip111 the order of servers is actually browser -> symfony proxy -> php webserver -> code. So the port you need to connect to is not the one from the php webserver.

@stof
Copy link

stof commented Sep 15, 2023

@tucksaun maybe the log message showing that port 45443 for the internal webserver should mention that this is not the port that should be connected to directly to remove confusion.

@tucksaun
Copy link
Contributor

the log message is directly streamed from PHP IIRC

@stof
Copy link

stof commented Sep 15, 2023

Well, there are 2 lines mentioning that port 45443. The second one is directly streamed from PHP but the first one comes from the webserver. Here, we might mention that this port 45443 is an internal implementation detail and should not be accessed directly.

@flip111
Copy link
Author

flip111 commented Sep 15, 2023

You can (and should) use the first port displayed (45431)

I tried it a few times and it didn't work to connect to this port and the other one did work. Maybe i overlooked something not sure, but i tried like 10 times. What else could i look at?

@flip111
Copy link
Author

flip111 commented Sep 15, 2023

By the way i found this thread #42 where a bunch of poeple posted saying it started to work after they installed php-fpm. Indicating that for their scenario php cli only does not work as they expected.

@tucksaun
Copy link
Contributor

Well, there are 2 lines mentioning that port 45443. The second one is directly streamed from PHP but the first one comes from the webserver. Here, we might mention that this port 45443 is an internal implementation detail and should not be accessed directly.

why not. any suggestion regarding the wording?

alternatively we could lower the message levels so that they are not shown by default?

@tucksaun
Copy link
Contributor

You can (and should) use the first port displayed (45431)

I tried it a few times and it didn't work to connect to this port and the other one did work. Maybe i overlooked something not sure, but i tried like 10 times. What else could i look at?

not sure but logs and/or error messages could help us narrow down the potential issue.

By the way i found this thread #42 where a bunch of poeple posted saying it started to work after they installed php-fpm. Indicating that for their scenario php cli only does not work as they expected.

this thread is about something else. as far as I know everyone in this thread was able to reach the CLI on the first advertised port.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants