As per suggestion here, I recently set up Laravel Valet as my local develop environment. This works great locally so far, but now I got curious about Laravel’s advertised sharing feature.
This feature allows you to run valet share on the command line and then a “publicly accessible URL will be inserted into your clipboard and is ready to paste directly into your browser” to share your site with the world, hosted from your local computer.
This generally works, however, it fails on all links set up via kirby. So it does not find any css files, js files or media files, as they all still link to Valet’s “local” link projectname.test/path/to/styles.css instead of the globally accessible link (which should look something like this I think: https://generatedprojectid.ngrok.io/path/to/styles.css. The panel (login) page does also not work, but I suspect this might be simply for the missing css files and such.
Does anybody know, if there is a kirby config setting or something similar that I can change to allow this setup to fully work?
I tried this too once, and got the same result. Its basically a proxy i think so kirby cant see it as a domain. i think theres a way to tell kirby the name of the domain its running instead of letting guess. I forget what its called but you can try setting that in the config. Have look a look in the reference guide, its there somewhere.
I think I tried that once and didn’t succeed. Or rather, it works if you put the url option in the main config, but it would only makes sense if you were able to put it in the domain specific config, and there you go round in circles again, because the domain specific config is not recognised. Try it yourself, it’s a while ago that I tried it and gave up on it.
I think if you pay for Ngrok you get a fixed address to use. The freebie version that comes with valet dishes out a random temporary one each time, which makes it harder.
I guess the bullet proof way would be to get a fixed IP form you broadband provider and point that at whatever.test via your hosts file. But check your broadband providers terms, some dont like you running a server off domestic broadband.
I have used the Valet share feature a few times with Kirby. What I did was run valet share then copy the Ngrok URL to the url config in Kirby. Then undo it after I’m done sharing.
Is there no way maybe to read out from which domain the site is accessed and then to dynamically write that into the Kirby structure and then serve the site with the correct links when the site is opened? Sorry, stupid question maybe, but I don’t know much about these things.
By localhost config you mean a file site/config/config.localhost.php, right?
When I do this, then links within the page link back to the localhost address (i.e. a link to the home page does not link to 123abc.ngrok.io, but to projectname.test).
But if I put it in the main config file, it works, I am fine with that. I only need to remove it once, when I deploy the final page.
Edit: And the panel would not work either, when I put it in the localhost file.
This is such a beautiful setup, I would almost recommed to include a litte paragraph about it on the Valet section of the local development environment page.
Now, what do I do with all the time I save by switching from my old terminal localhost to Valet?
Valet+ is a third-party fork of Laravel Valet. The principle is the same as outlined above, but as its name suggest, Valet+ comes with some additional features like PHP version switching or Xdebug on/off mode, which you can check out in the documentation.
Looks like the standard official Valet now offers PHP switching, but Valet + still offers a bunch of useful extras (i use mailhog all the time for email testing). You just might want to clarify that paragraph slightly since it out of date now.