Valet driver for Trellis + Bedrock

If anyone would like to use a Laravel Valet dev environment with a Trellis directory structure (for deploying/provisioning staging and production servers), you’ll need a custom driver. If so, check out https://github.com/danielroe/trellis-valet-driver.

Note: Using Valet rather than Trellis creates distance between your dev & production environments. See this note for more.

10 Likes

Nice! Thanks for sharing :slight_smile:

1 Like

So with the new Valet Driver, is there a command to use instead of Vagrant Up or do I need to setup my database and wordpress install separate?

If you are using Valet, then you won’t be using vagrant or running vagrant up.

Instead, you will be provisioning your database and editing your .env file by hand, or (possibly) using the excellent wp-cli-valet-command to do it automatically.

2 Likes

Hey @danielroe, this is exactly what I’ve been looking for (I think). I love the speed and simplicity of Valet for working locally, but also like the idea of Trellis for .env stuff and deploys.

I followed the instructions in your read me, and ran valet install afterwards for good measure.
My ~/Sites/ directory is valet parked.

This site is already set up in Trellis and in a directory named with the tld; my-site.io. I’m not having any luck browsing to my-site.io.test or my-site.test - I get a 502 bad gateway nginx error for the former, and a timeout error for the latter.

What can I try in order to get this working? Would you expect my-site.test or my-site.io.test to work out of the box? Many thanks for any tips or suggestions!

@ng3 Does site/.env contain the following lines?

WP_HOME=http://my-site.io.test
WP_SITEURL=http://my-site.io.test/wp

If so, would you run cd ~/Sites/my-site.io/site/ && valet link and then tell me what happens when you visit site.test? I would expect it to redirect you to my-site.io.test.

:man_facepalming:

There’s no .env file. What a schoolboy error! I guess I got something wrong along the way, or perhaps Trellis only creates the .env file on vagrant up?

Anyway, thanks very much for the reply, and I’ll create the .env file manually.

You’re quite right; I should flag that up. (Now done.)

Lol, I went back to the read me and thought I’d missed a step. I still couldn’t get it working after creating the .env file.

I did cd ~/Sites/my-site.io/site/ && valet link but didn’t get anything at site.test or a redirection. I was redirected from my-site.test to mysite.io.test but then got the error again.

Does it make any difference that I’ve already had this running in a VM via vagrant up? I destroyed the VM and deleted the files, but I’m wondering if there’s some dns issues left over…

Just to check, have you provisioned a database and imported from your Trellis install?

If you’ve already done that, try looking in the Valet logs (in ~/.valet/Log). You might also check that Valet is using the Trellis driver (cd ~/Sites/my-site.io && valet which).

1 Like

Thanks! Yes - valet which gave your trellis driver.

I think this may be a Valet issue rather than your driver (none of my valet sites are working anymore), so feel free to bow out gracefully with a :taco: and :beers: for your time!

I get an error saying valet.sock can’t be found. And somewhere else I get an error saying there is another service listening to valet.sock so Valet can’t use it.

I’ve been through brew doctor and removed all PHP and installed just php72. Apparently HomeBrew now puts php in /core rather than /php.

I’ve uninstalled Valet, and re-installed it. I’ve done composer global update. Still no luck with Valet sites working.

I tried a fresh install using wp valet new hope-to-god-this-works --project=bedrock and I get a success message, but the connection is refused at hope-to-god-this-works.test.

So for now I have gone back to using Trellis and vagrant up which works fine.

Damn you Valet, I was so in love with you and now you go and do this… :sleepy:

Just wanted to loop back round and update this - my problem was that valet wasn’t listening to port 80. After doing this:

some stuff

Which I think culminated in

valet uninstall
rm -rf ~/.valet
composer global remove laravel/valet
composer global require laravel/valet
valet install

I got a pop up asking if Valet was allowed to listen to port 80, and then everything worked again.

Thanks again for your time @danielroe

1 Like

I’m really glad it turned out all right - and my apologies for my silence! (This dropped off my radar for some reason.)