Laravel Valet - This Site Can't Be Reached - macos

I have successfully followed the Setup a Mac Dev Machine until this tutorial: https://laracasts.com/series/setup-a-mac-dev-machine-from-scratch/episodes/10?autoplay=true
The problem is that when I go to SITENAME.dev, nothing shows up. Instead, I get the following message:
This site can’t be reached
test2.dev refused to connect. Did you mean http://test2.de/? Search Google for test2 dev ERR_CONNECTION_REFUSED
I've tried this both for a laravel install (using the laravel installer) and a wordpress install. Neither one works.
Any idea why it is not working. I have followed the course step-by-step as well as the comments. For instance, I modified the .zshrc file as follows based on the course and comments:
export PATH=$HOME/bin:/usr/local/bin:$HOME/.composer/vendor/bin:$PATH
And, in case it is relevant, I am on Mac Sierra (freshly updated).
In short, where Jeffrey is able to get a home page of laravel, I get an error.
Any idea how to fix this?
Thanks.

Go to your site folder and execute the following commands:
cd your_project
composer global update
valet uninstall
rm -rf ~/.valet
rm -rf ~/.config/valet
valet install
valet link
valet open
It fixed this issue for me, and particularly after PHP upgrades.

Mac os mojave - version 10.14,
cd in your-project-folder-name and run
valet secure your-project-folder-name

Solution:
composer global update
brew upgrade nginx
cd your_project
valet start
For more details read this blog
https://medium.com/#panjeh/valet-this-site-cant-be-reached-err-connection-refused-ad424ea1e343

Have you actually started the valet service? Head over to the directory that you ran
$valet park
in, I'm assuming it's where you've also placed your project and type:
$valet start
into the terminal. That works for me.

Be sure you're over http://app.test and not https://app.test
Laravel Valet uses Not secure http as default.
By the way if you want to secure your app then use
valet secure YOURAPPNAME

Deleting the file (sudo rm /etc/resolver/dev) will clear this issue up.

IF valet is trying to open a HTTPS (SSL connection) type command line in your terminal
valet secure

Related

Laravel error - Class setEventDispatcher does not exist

Short version
I'm getting this error, when I run php artisan serve and visit my home page:
ReflectionException (-1)
Class setEventDispatcher does not exist
Details
Laravel version: 5.6.39
Environment: local
OS: macOS Mojave 10.14.2
It started, when I got an error using npm (in another project), so I reinstalled Node (this way).
After doing that, then this project (in question) couldn't be started. I was getting this error, when running php artisan serve:
dyld: Library not loaded: /usr/local/lib/libpng16.16.dylib with anything php related
Referenced from: /usr/local/bin/php
Reason: image not found
That error was resolved by updating and upgrading brew.
Then I was capable of starting the project (php artisan serve). But when I visit the home page, this error was shown:
ReflectionException (-1)
Class setEventDispatcher does not exist
If I follow the stack trace, then I can see that it was this line (from my homeController) that triggered the error:
if( ! Auth::check() ){
return view( 'pages.home' );
}
If I commented that out, then the same error occured from another place, where the Auth-module was being used.
Here's the stack trace:
Does anyone know how to resolve this? I can't find any promising results on Google, - and I have no idea why this happens... :-/
Addition1
I tried composer clear-cache and deleting the vendor-folder, and then doing a composer install and the problem still occured.
I also checked my Service Providers, as Marcus suggested, - but I don't really know what to look for in there. It all looks pretty regular (no fancy if-statements or anything).
Addition2
I realized, that I couldn't connect to my database using Sequel Pro. And it was because Brew had updated my MySQL-version from 5.5 to 8.0.
That was resolved by doing something along these lines (I did a bunch of stuff, so I might be missing a coulple of steps):
brew unlink mysql
brew install mysql#5.7
brew switch mysql 5.7.21
brew link mysql
and I could then verify the version with mysql --version. I also had some permission issues with that MySQL-version-change, but I'm emitting that, so this doesn't get too long.
Addition3
I tried disabling the Laravel Debugbar (by deleting it from composer.json, deleting composer.lock and vendor and then running composer install). And that fixed it!! ... But!
When I later tried to install Barryvdh's IDE Helper, then the exact same error came back!?
I performed these three steps, to install the IDE Helper (and re-introduce the error):
Run this command from the root of my directory: curl https://gist.githubusercontent.com/barryvdh/5227822/raw/4be028a27c4ec782965bb8f2fdcb4c08c71a441d/_ide_helper.php -o _ide_helper.php
Add these lines to app/Provider/AppServiceProvider.php:
...
if ($this->app->environment() !== 'production') {
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
}
Run this command: composer require --dev barryvdh/laravel-ide-helper
So I'm back at this error:
ReflectionException (-1)
Class setEventDispatcher does not exist
... The stack trace is identical to the one shown previously (sprung from Container.php).
Tried every solution, none of them worked.
Finally, i realised that when trying to upgrade php to 7.3.3 it was infact a network error that caused the fail. Read the logs, tried again, restarted valet and tried again.
It works now.
Upgrading to 7.3.3 was the solution indeed.
Thank you!
So this is what usually fixes it for me
Reinstall composer dependencies by removing vendor folder and composer.lock. Then run composer clear-cache and then composer install (this is usually the problem)
Check that all service providers are imported correctly in app.php under directory config
Make sure that your service providers are not importing something that does not exist, for example if you register a service provider in production but is only installed as dev:
if (env('APP_DEBUG')) {
$app->register(Barryvdh\Debugbar\LumenServiceProvider::class);
}
If you use valet, I solved it running
valet restart and all works fine.
cheers!
The fix for me was to update PHP to 7.3.3 and then restart valet. Apparently this was a bug with php 7.3
https://github.com/laravel/framework/issues/27052
Hope this helps
I got some idea... I've just run into this problem after reconfiguring my apache virtual host ports, so I restarted apache/httpd again, and the problem went away. Might it be related with the server environment?
I am facing the same issue in mac book pro. My system configuration is PHP 7.3, MySQl and I use SQL Pro. I have implemented all the above methods but nothing gets worked.
The issue is still a mystery for me but for temporary I have solved this issue using
artisan command as bellow.
php artisan serve
Its Allow me to run the project on http://localhost:8000
Hope this can help to solve this issue.
Try to restart PHP. When I reboot my Mac, then this happens. After restarting PHP everything starts to work.
sudo brew services restart nginx

Hyperledger composer disappears after turning off the PC

I follow this guide for installation (on Mac)
https://hyperledger.github.io/composer/latest/installing/development-tools.html#appendix
and this one for developing a business network
https://hyperledger.github.io/composer/v0.16/tutorials/developer-tutorial
everything is fine, unless when I shutdown the computer, the composer seems to be uninstalled!! Mac's terminal does not recognize composer commands and I have to uninstall and install all them again! Can you give your idea about what the cause is? Thanks
Make sure You have install all composer package with -g and Not using nvm. If using nvm then make sure to be on same version every time you use composer command.

404 - Not Found when I try to browse to my local WebServer using the IP

So I'm developing responsive websites and obviously need to test these via phones and tablets and it used to work fine, up until yesterday, after I tried installing js frameworks like npm.
For some reason, when I browse to my local testing using the ip it get:
404 - Not Found
I've been used to using:
http://192.168.0.2/filename.php
I've tried:
http://192.168.0.2:8080/filename.php
...still get 404 - Not Found
I've restarted Apache and checked the the port is correct, and it is.
Listen 80
This happened before when I installed Laravel and Valet, but not long after that I had to wipe my Mac due to work and it started working again with a fresh install.
Am I missing something in Apache? does npm and Laravel mess with the Apache settings?
Locally, everything works fine. I can browse to localhost/filename.php directly using Mac with PHP and MySQL talking to each other, albeit after using Homebrew to install MySQL, PHP connections now only accepts 127.0.0.1 rather than localhost.
I've set all the permissions to "everyone" there should be no access issues.
I've noticed another oddity with Firefox Dev Ed too. When I've been using Valet or Gulp, it stops connecting and give a Cannt connect to server error, but Safari and Chrome seem to work ok.
If anyone can shed some light on this, I'd be happy to give it a go!
All fixed! It was Larvel's Valet installation that was causing the issue, as suspected.
So, looked at the brew Cellar directory in /usr/local/Cellar, but it wasn't actually in there. Then opened up Terminal and typed:
valet install
Then ran valet by typing:
valet
Then uninstalled valet by typing:
uninstalled valet
Then restarted Apache2 by typing:
sudo apachectl restart
adding password
Booted up the browser and browsed to localhost/info.php which holds the line <?php phpinfo() ?> and HAPPY DAYS :)

Valet - phpMyAdmin throws 404 not found

Before installing Laravel and Valet on my dev environment (Ubuntu), I had installed PHP 7, MySQL and phpMyAdmin and everything was working fine.
In order to install Valet I had to disable apache2 as Valet was complaining during the instalation and add nginx and follow these steps https://github.com/cpriego/valet-linux/wiki/Requirements:%20Ubuntu
However after the instalation when I try to access the phpMyAdmin through the browser I'm getting the default white page 404 - not found. How can I fix this?
You have parked your workspace directory using
valet park
Clone the phpmyadmin repository using
git clone https://github.com/phpmyadmin/phpmyadmin --depth=1
cd phpmyadmin
composer install
In the same directory just download phpmyadmin package & extract it. You will be able to access it from
http://phpmyadmin.test
If you have phpmyadmin already installed from your last setup, you don't have to download it & install it again.
I was facing the same thing migrating to valet from lamp, this is what I did:
1- Navigate to original phpmyadmin folder
cd /usr/share/phpmyadmin
2- Then add a link to valet
valet link
Hooray! you can now access it at: phpmyadmin.test
If you changed a port 8080. You can try this
localhost:8080/phpmyadmin/
I tried this and it failed to work for me, I found a workaround, check the link for my solution: https://stackoverflow.com/a/47211246/8768078

Laravel valet It works

I'm trying to install Laravel valet but I keep getting (when I visit domain.dev):
It works!
I already tried a lot. For example:
remove valet
stop apache (apachectl stop)
composer global require laravel/valet
valet install
valet restart
But that does not work for me. I've also installed Laravel Homestead in a vagrant box. Perhaps that has something to do with it? I can visit my Homestead sites.
How can I fix this problem?
"It works!" will always be a message from Apache.
Apache has to be turned off for Laravel Valet to work.
I see you have tried these before:
$ stop apache (apachectl stop)
$ sudo apachectl -k stop
I had the same problem. Try with the command below and then after be sure to restart valet again! This fixed it for me:
$ sudo apachectl stop
$ valet restart
So many different combinations of what to do here
Here is what worked for me.
Turn off other local Apache altogether
sudo apachectl -k stop
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
Remove the Valet directory altogether
rm -r ~/.valet
Removed Valet via composer globally
composer global remove laravel/valet
Re-install via composer
composer global require laravel/valet
Install Valet
valet install
Go to Folder to Add directories
cd ~/Sites/
Then add projects to park
valet park
Change Valet domains to something else to stop urls forcing to https://
valet domain app
Change directory into the project folder
cd ./laravel-project/
Then open current project
valet open
The browser should open to http://laravel-project.app
No need to stop Apache, and it doesn't have anything to do with Homestead.
The answers provided solve your problem but they are not good.
You can simply run
valet port 8888
(or whatever port you want) and get your site on domain.dev:8888
The point is not that Apache and Nginx don't like each other, they are agnostic of each other, just keep them listening on different ports.

Resources