Skip to content

Conversation

@Kocal
Copy link
Contributor

@Kocal Kocal commented Nov 11, 2025

Related to #639

Passing the flag --open to symfony serve or symfony server:start open the first reachable URL in the default web-browser.

@Kocal Kocal changed the title Add --open to server:start command Add --open flag to server:start command Nov 11, 2025
@fabpot
Copy link
Contributor

fabpot commented Nov 12, 2025

I'm not sure I'd like to always open a browser.
Overall, I'm not convinced that this is "useful".

@Kocal
Copy link
Contributor Author

Kocal commented Nov 12, 2025

I think it depends on what kind of project you're working. Indeed that's not useful for an API-oriented application, but it is for a Twig-based app.

I've worked on quite a few JavaScript projects (mostly based on Vite), and having the app open automatically in the browser was super convenient.

Here, the option is disabled by default, and it helps to resolves #639 (where you have to scroll a tons of log to find the application URL). I think that's fine?

Comment on lines 151 to 158
func abstractOpenCmd(url string) {
if err := open.Run(url); err != nil {
terminal.Eprintln("<error>Error while opening:", err, "</>")
terminal.Eprintfln("Please visit <href=%s>%s</> manually.", url, url)
} else {
terminal.Eprintfln("Opened: <href=%s>%s</>", url, url)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opening an URL does not really makes sense outside of an interactive context (ie when running a command). So I would not move it to utils.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I wasn't really sure, I just wanted to centralize this logic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure where to put it, so I simply reverted my changes and duplicated the block to open the URL in the browser

@tucksaun
Copy link
Member

I think I agree with @fabpot here: while I see the use of the --open flag, I'm not sure having it the configuration is that useful

@Kocal
Copy link
Contributor Author

Kocal commented Nov 13, 2025

@tucksaun
Copy link
Member

I'm not saying we can't, I'm saying I'm not sure this is that useful (again in the configuration as I'm convinced of the flag.

Because from experience I usually do something like symfony serve && symfony open:local and switch back and forth with symfony serve depending on my needs.

But I'm not against having it

@fabpot
Copy link
Contributor

fabpot commented Nov 14, 2025

I'm fine adding the --cloud flag, without adding an option in the configuration file.

@Kocal Kocal force-pushed the feat/server-start-open branch from ee0faee to 88da774 Compare November 14, 2025 07:46
@Kocal
Copy link
Contributor Author

Kocal commented Nov 14, 2025

I just removed the open option from the configuration file.

@tucksaun
Copy link
Member

tucksaun commented Nov 14, 2025 via email

@Kocal Kocal force-pushed the feat/server-start-open branch from 88da774 to c2ead21 Compare November 14, 2025 22:37
@Kocal Kocal requested a review from tucksaun November 14, 2025 22:37

NoWorkers bool
Daemon bool
Open bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be part of the config. Instead, you should create a flag in the server:start command directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, there's no need for that anymore.

Fixed!

@Kocal Kocal force-pushed the feat/server-start-open branch from c2ead21 to 7cbdcd8 Compare November 15, 2025 08:34
@Kocal Kocal force-pushed the feat/server-start-open branch from 7cbdcd8 to 1522ce6 Compare November 15, 2025 08:35
@Kocal Kocal requested a review from fabpot November 15, 2025 08:35
@fabpot
Copy link
Contributor

fabpot commented Nov 20, 2025

Thank you @Kocal.

@fabpot fabpot merged commit d50c03a into symfony-cli:main Nov 20, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants