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, or configuring open: true in the .symfony.local.yaml, will now 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.

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

Choose a reason for hiding this comment

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

Suggested change
if err := open.Run(applicationUrl); err != nil {
terminal.Eprintln("<error>Error while opening:", err, "</>")
terminal.Eprintfln("Please visit <href=%s>%s</> manually.", applicationUrl, applicationUrl)
} else {
terminal.Eprintfln("Opened: <href=%s>%s</>", applicationUrl, applicationUrl)
}
abstractOpenCmd(applicationUrl);

should be enough. or did I miss something?

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