Skip to content

feat(docs): add autocompletion docs#2010

Open
alexandre-daubois wants to merge 8 commits intophp:mainfrom
alexandre-daubois:autocomplete
Open

feat(docs): add autocompletion docs#2010
alexandre-daubois wants to merge 8 commits intophp:mainfrom
alexandre-daubois:autocomplete

Conversation

@alexandre-daubois
Copy link
Member

No description provided.

@henderkes
Copy link
Contributor

Huh neat, I had no idea this was a thing.

Copy link
Contributor

@henderkes henderkes left a comment

Choose a reason for hiding this comment

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

should we add this to the rpm/deb packages?

@henderkes
Copy link
Contributor

henderkes commented Nov 23, 2025

Hmm, bash autocompletion isn't working for me. Neither on RHEL 10 nor on Trixie. I checked with caddy completion bash and that works.

Copy link
Contributor

@henderkes henderkes left a comment

Choose a reason for hiding this comment

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

Completion is broken because it installs it for caddy, not for frankenphp.

We could fix it with source <(frankenphp completion bash | sed 's/caddy/frankenphp/g') if there's no better way to replace it in code.

@henderkes
Copy link
Contributor

alexandre-daubois#4

@alexandre-daubois
Copy link
Member Author

alexandre-daubois commented Nov 23, 2025

That's strange, I'm not sure how I made it work then 🤔 This is curious, I need to investigate this.

sed would indeed do the job, but I don't know how much I find it too hacky to put it in the docs then

And thanks for the PR on my fork, I'll have a deeper look tomorrow!

@henderkes
Copy link
Contributor

Perhaps there's something like the CustomVersion parameter that we need to set to update the binary name? @mholt would likely know, I've googled without much luck.

@mholt
Copy link
Contributor

mholt commented Nov 24, 2025

@henderkes Letsee... I didn't implement that, I think we're using Cobra for completion generation. I dunno if that gives you enough of a hint, I'll keep looking for a few minutes before I have to move onto something else. But I think @mohammed90 might have an idea.

@mholt
Copy link
Contributor

mholt commented Nov 24, 2025

Oh, did you run the completion command with caddy? If so, try running as frankenphp... I have no idea if that would make a difference, but...

@henderkes
Copy link
Contributor

Oh, did you run the completion command with caddy? If so, try running as frankenphp... I have no idea if that would make a difference, but...

It's running with frankenphp completion bash, but spits out caddy regardless.

@mholt
Copy link
Contributor

mholt commented Nov 24, 2025

@henderkes I might have found it:

https://github.com/caddyserver/caddy/blob/67a9e0657e60df8c78510065e8977d86ee17d01c/cmd/cobra.go#L13

If you change that line, does it have the expected results for you?

@henderkes
Copy link
Contributor

I'll figure out how to make xcaddy build with a local caddy source tree and report back... hopefully tomorrow. If not, it will have to wait until next week after SymfonyCon. Thank you for your input!

@mholt
Copy link
Contributor

mholt commented Nov 24, 2025

xcaddy build --with github.com/caddyserver/caddy/v2=../caddy or something like that, should do the trick.

I am a bit busy atm or I'd just check for you.

If changing that variable does work (again, I don't know the internals of Cobra, so it's a guess, but probably a good one), we can find a way to export that or somehow accommodate your build process.

@mohammed90
Copy link

Matt is right, Cobra takes the name of the root command, which in our case is Caddy.

https://github.com/spf13/cobra/blob/fc81d2003469e2a5c440306d04a6d82a54065979/completions.go#L824

I'm not sure how we could modularize it, from the top of my head.

@mholt
Copy link
Contributor

mholt commented Nov 25, 2025

We could probably export it to a package-level variable, that can be changed at init-time... or some sort of const that gets changed during a build step, I dunno.

@henderkes
Copy link
Contributor

Perhaps similar to how we can overwrite the version output?

@mholt
Copy link
Contributor

mholt commented Dec 4, 2025

Yeah, kind of like the caddy.CustomVersion variable.

@alexandre-daubois alexandre-daubois marked this pull request as draft December 4, 2025 18:14
@alexandre-daubois
Copy link
Member Author

Let's convert this one to draft, I'll have a deeper look whenever I have some bandwidth. Thanks for the hints!

@alexandre-daubois
Copy link
Member Author

I just created caddyserver/caddy#7513 to move the project forward

@alexandre-daubois
Copy link
Member Author

The PR has been merged! We'll need to wait for a caddy release, but the code is here

@henderkes henderkes marked this pull request as ready for review March 2, 2026 16:55
@henderkes
Copy link
Contributor

Setting as active then. I'm setting the completion in my packages already, but there's no good way to set it up in this repo as we only define scripts, not file mappings.

@alexandre-daubois
Copy link
Member Author

#2244 unlocked this PR, I'll take care of it soon

@alexandre-daubois alexandre-daubois force-pushed the autocomplete branch 2 times, most recently from ba862cb to 2968ad5 Compare March 9, 2026 15:05
Copy link
Contributor

@henderkes henderkes left a comment

Choose a reason for hiding this comment

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

Could you create the pr at homebrew? I'll take care of static-php-cli tomorrow.

@alexandre-daubois
Copy link
Member Author

Could you create the pr at homebrew?

I'm not sure why is it required?

@henderkes
Copy link
Contributor

The CustomVersion/CustomBinary arguments needs to be given to the linker,. Homebrew/spc/docker each have their own linking phases and arguments, hence they need to be added to each.

@henderkes
Copy link
Contributor

@alexandre-daubois
Copy link
Member Author

Oh alright! I'm not familiar with Homebrew packages providing. That's noted for the next time, thank you very much for taking care of it!

Copy link
Contributor

@henderkes henderkes left a comment

Choose a reason for hiding this comment

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

Sorry for being nitpicky, but the linux locations should match my packages.

Pour charger l'autocomplétion à chaque nouvelle session, voici la commande à exécuter :

```powershell
frankenphp completion powershell >> $PROFILE
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be a better idea to create a file next to $PROFILE and tell $PROFILE to load it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Used Claude to help me on this one, I don't have a Windows computer. If someone has one, I'd be happy to know if the command is correct 👍

Copy link
Contributor

@henderkes henderkes left a comment

Choose a reason for hiding this comment

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

Looks great!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants