Closed lolsokje closed 11 months ago
Your post shows that you're running Valet 4.0.0
.
The latest is 4.1.4
, and a few PRs have been merged to handle a few glitches with custom drivers, including #1414
I suggest running composer global update laravel/valet
or just composer global update
to get the latest Valet updates. That will help rule out whether the problem has already been addressed.
Updated to 4.1.4
but the issue persists.
You wrote:
I'm extending the LaravelValetDriver as the frontControllerPath method is the same for Symfony as it is for Laravel and can thus be omitted.
While half of that is true, extending the Symfony driver solves the problem.
The following works for me.
-use Valet\Drivers\LaravelValetDriver;
+use Valet\Drivers\Specific\SymfonyValetDriver;
-class CustomValetDriver extends LaravelValetDriver
+class CustomValetDriver extends SymfonyValetDriver
Edit: I would recommend renaming from CustomValetDriver
to something more context-specific. Or use the LocalValetDriver approach mentioned below...
FURTHER ...
Since this driver is highly specific to a certain project (referring to your serves()
method customizations), why not just call it LocalValetDriver
and stick it directly in your project's root directory? That way Valet will look at that first.
-namespace Valet\Drivers\Custom;
+//namespace Valet\Drivers\Custom;
use Valet\Drivers\Specific\SymfonyValetDriver;
-class CustomValetDriver extends SymfonyValetDriver
+class LocalValetDriver extends SymfonyValetDriver
As for serving static assets, you might find some ideas from this post I made responding to someone else's desire for serving static files: https://github.com/laravel/valet/discussions/1430#discussioncomment-6536474
You wrote:
I'm extending the LaravelValetDriver as the frontControllerPath method is the same for Symfony as it is for Laravel and can thus be omitted.
While half of that is true, extending the Symfony driver solves the problem.
The following works for me.
-use Valet\Drivers\LaravelValetDriver; +use Valet\Drivers\Specific\SymfonyValetDriver; -class CustomValetDriver extends LaravelValetDriver +class CustomValetDriver extends SymfonyValetDriver
Edit: I would recommend renaming from
CustomValetDriver
to something more context-specific. Or use the LocalValetDriver approach mentioned below...
Using Valet\Drivers\Specific\SymfonyValetDriver
indeed fixed the issue! I tried using Valet\Drivers\SymfonyValetDriver
already but the class couldn't be found, I forgot to check what namespace the framework specific drivers have though, that's my bad. Although maybe it could be mentioned more clearly in the documentation.
The driver already has a specific name, I simply chose CustomValetDriver
for anonymity sake.
FURTHER ...
Since this driver is highly specific to a certain project (referring to your
serves()
method customizations), why not just call itLocalValetDriver
and stick it directly in your project's root directory? That way Valet will look at that first.-namespace Valet\Drivers\Custom; +//namespace Valet\Drivers\Custom; use Valet\Drivers\Specific\SymfonyValetDriver; -class CustomValetDriver extends SymfonyValetDriver +class LocalValetDriver extends SymfonyValetDriver
Right now it's only one project using this custom driver, but in the future I'll need to re-use it for others, so I'm not using a local driver for that reason. I'll simply rewrite the serves
method when necessary.
Right now it's only one project using this custom driver, but in the future I'll need to re-use it for others, so I'm not using a local driver for that reason. I'll simply rewrite the serves method when necessary.
Fair. You might be able to simply have the serves()
method return true
if it's a LocalValetDriver
file, since it looks at that file first. Then even fewer rewrites required between projects ;)
Description
I've created the following custom driver in
~/.config/valet/Drivers
, as I need to handle static files in a specific manner;I'm extending the
LaravelValetDriver
as thefrontControllerPath
method is the same for Symfony as it is for Laravel and can thus be omitted.The driver is picked up correctly, but gives me the following error;
Without the custom driver, or even when extending the base
ValetDriver
class, the site loads fine but assets don't work (which is why I need the custom driver in the first place).Steps To Reproduce
symfony new [project] --webapp
valet link
Diagnosis
sw_vers
valet --version
cat ~/.config/valet/config.json
cat ~/.composer/composer.json
composer global diagnose
composer global outdated
ls -al /etc/sudoers.d/
brew config
brew services list
brew list --formula --versions | grep -E "(php|nginx|dnsmasq|mariadb|mysql|mailhog|openssl)(@\d\..*)?\s"
brew outdated
brew tap
php -v
which -a php
php --ini
nginx -v
curl --version
php --ri curl
/opt/homebrew/bin/ngrok version
ls -al ~/.ngrok2
brew info nginx
brew info php
brew info openssl
openssl version -a
openssl ciphers
sudo nginx -t
which -a php-fpm
/opt/homebrew/opt/php/sbin/php-fpm -v
sudo /opt/homebrew/opt/php/sbin/php-fpm -y /opt/homebrew/etc/php/8.2/php-fpm.conf --test
ls -al ~/Library/LaunchAgents | grep homebrew
ls -al /Library/LaunchAgents | grep homebrew
ls -al /Library/LaunchDaemons | grep homebrew
ls -al /Library/LaunchDaemons | grep "com.laravel.valet."
ls -aln /etc/resolv.conf
cat /etc/resolv.conf
ifconfig lo0
sh -c 'echo "------\n/opt/homebrew/etc/nginx/valet/valet.conf\n---\n"; cat /opt/homebrew/etc/nginx/valet/valet.conf | grep -n "# valet loopback"; echo "\n------\n"'
sh -c 'for file in ~/.config/valet/dnsmasq.d/*; do echo "------\n~/.config/valet/dnsmasq.d/$(basename $file)\n---\n"; cat $file; echo "\n------\n"; done'
sh -c 'for file in ~/.config/valet/nginx/*; do echo "------\n~/.config/valet/nginx/$(basename $file)\n---\n"; cat $file | grep -n "# valet loopback"; echo "\n------\n"; done'