verbb / icon-picker

A Craft CMS field to select SVG or font icons from a folder for use in your content.
Other
17 stars 8 forks source link

A little note for Valet users #7

Closed 1stevengrant closed 1 year ago

1stevengrant commented 5 years ago

You'll need to update /etc/hosts if using the plugin locally with Laravel Valet

eg 127.0.0.1 craftsandbox.test

Else, Guzzle fails

jacobgraf commented 5 years ago

Thanks @1stevengrant - I just ran across this too. Hope they fix it somehow! :-)

oscarehrling commented 5 years ago

Thank you @1stevengrant !

engram-design commented 5 years ago

@1stevengrant Can you let me know what error you're getting from Guzzle?

1stevengrant commented 5 years ago
GuzzleHttp\Exception\ConnectException
cURL error 6: Could not resolve: craft3.test (Domain name not found) (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
engram-design commented 5 years ago

@1stevengrant I did make some URL fixes in 1.0.5, so might be worth checking that out.

I assume craft3.test is indeed the domain your site is running on?

1stevengrant commented 5 years ago

yeah, updated to 1.0.5 but still the same on both issues.

engram-design commented 5 years ago

@1stevengrant I've been talking briefly with @jalendport about this (the master of Valet), it seems like this is an issue with curl-openssl for Valet.

Running the following seems to help:

brew uninstall curl-openssl --ignore-dependencies
brew services restart php@7.1
valet restart
jalendport commented 5 years ago

To provide a little more context to Josh's comment:

I ran into this the other day with Andrew's Image Optimize plugin (it uses curl to get the optimized image variants in the CP when you double-click on an asset). I traced the problem down to the curl-openssl formula which is a dependency of all the PHP formulas you can install via Brew.

It seems curl-openssl doesn't read the dnsmasq config (dnsmasq is what tells your computer that anytime you visit a .test domain it should use your localhost instead of trying to run a dns query or ping a live serve; it is similar in idea to your /etc/hosts file, but with /etc/hosts you would have to add each .test site, whereas dnsmasq is more of a wildcard solution), so it has no knowledge of your Valet domains. So when you remove curl-openssl, PHP will fallback on your Mac's default install of curl, which seems to read the dnsmasq config just fine.

(Disclaimer: I can't say for certain that removing curl-openssl won't do something "bad" in the long run, but I know that Valet and Craft seem to run fine without it. If worse were to ever come to worse, all you would ever have to do is just reinstall it and restart PHP/Valet.)

So I think short-term, adding them to the hosts file is fine. The only way I've found to "permanently" fix it for all your Valet sites is to uninstall curl-openssl. Ideally someone finds a way to edit the curl config or your php config so that curl-openssl functions the same as the default curl.

khalwat commented 3 years ago

Relevant: https://discourse.brew.sh/t/brews-curl-openssl-cant-resolve-localhost-hostnames-set-up-in-dnsmasq-system-curl-has-no-issue/5327