DEV Community

Cover image for Running PWA Laravel on Another Devices
Juan
Juan

Posted on

Running PWA Laravel on Another Devices

PROBLEM DEVELOPING PWA IN LARAVEL

Recently, I developed a laravel apps that implement Progressive Web Apps. After I finish this app, I was curious about How Can I Test this app on another devices like phones or tablets ?!.

FINDING SOLUTION

I try to serve development server laravel with custom host that connecting my laptop and my phone. Like php artisan serve --host someIP --port somePORT, but it doesn't work lol. I can visit my web app but I don't know why the service worker didn't want to be loaded. I assumed it just because SSL problem.

Then I start googling again how to serve laravel development server with SSL/https ?!?!. Many of articles and SOF suggest me to make virtual host with nginx or ngrok. I searched it but I can't follow the steps it's pretty hard for me to follow.

SOLUTION

After few days I search it on google and I found a solution to solve this problem with port forwarding. Yep it's simple. Just follow step below

  1. First you have to start your laravel project with normal command php artisan serve.
  2. Prepare your phone (cause I am using phone) with developer option is on and make sure usb debugging is on too. Shortly Make sure your phone in debug mode.
  3. After that, connect your phone with usb cable to your laptop/PC.
  4. After your devices connected to each other, just visit this chrome://inspect#devices Image description
  5. Then, choose port forwarding.
  6. Insert your localhost and it's port. Image description
  7. Make sure check enable port forwarding. Then, Click Done.
  8. At Last, visit localhost with port using your phone.

And it will load your service worker as well. Cheerss !!!!. If you find this solution difficult to understand, feel free to ask in comment below.

Discussion (0)