phayes0289's avatar

How to View My Laravel project from Another Computer

I am currently developing my project on a Mac Studio. I am using Valet to preview the project in a web browser. One... How can I access my project from another device, such as an iPhone or a Macbook, within the same network? Two... is it possible to view it from outside my home office network?

0 likes
7 replies
LaryAI's avatar
Level 58

To view your Laravel project from another computer within the same network, you can follow these steps:

  1. Find the IP address of your Mac Studio computer. You can do this by going to System Preferences > Network and looking for the IP address listed under "Status" or "Wi-Fi."

  2. On the other device (e.g., iPhone or Macbook), make sure it is connected to the same network as your Mac Studio computer.

  3. Open a web browser on the other device and enter the IP address of your Mac Studio computer followed by the port number used by Valet. By default, Valet uses port 80, so the URL would be something like http://192.168.0.100:80 (replace 192.168.0.100 with the actual IP address of your Mac Studio computer).

  4. If everything is set up correctly, you should be able to view your Laravel project on the other device.

To view your Laravel project from outside your home office network, you will need to set up port forwarding on your router. Here's how you can do it:

  1. Find the IP address of your Mac Studio computer (as mentioned in step 1 above).

  2. Access your router's settings by typing its IP address into a web browser. The IP address is usually something like 192.168.0.1 or 192.168.1.1. If you're not sure, consult your router's documentation.

  3. Look for the port forwarding or virtual server settings in your router's settings. The location and terminology may vary depending on your router's make and model.

  4. Add a new port forwarding rule. Specify the following details:

    • Service/Name: You can enter any name for the rule.
    • Internal IP/Device IP: Enter the IP address of your Mac Studio computer.
    • Internal Port/Device Port: Enter the port number used by Valet (default is 80).
    • External Port: Choose a port number that you want to use to access your Laravel project from outside your network. For example, you can use port 8080.
  5. Save the settings and exit the router's settings interface.

  6. On the device outside your home office network, open a web browser and enter your public IP address (you can find this by searching "what is my IP" on Google) followed by the port number you specified in the port forwarding rule. For example, the URL would be something like http://123.456.789.123:8080 (replace 123.456.789.123 with your public IP address and 8080 with the port number you chose).

  7. If everything is set up correctly, you should be able to view your Laravel project from outside your home office network.

Please note that exposing your local development environment to the internet can pose security risks. Make sure to take appropriate precautions, such as using strong passwords and keeping your system and Laravel project up to date with security patches.

MohamedTammam's avatar

Usually you can visit your website if you visit your local network ip followed by the website port (default 80 or 443).

If you want to share your website with others, you have multiple options

1- Sail share

2- ngrok

3- Cloudflare Tunnel

Currently, I use Cloudflare Tunnel for working with webhooks from third party services. It's free and I recommend it.

1 like
nexxai's avatar

Laravel Herd (Valet's replacement) has BeyondCode's Expose built right into it.

Snapey's avatar

+1 for expose

If you go down one of these routes make sure you change the app_url to be the same as the external url so that your assets have correct links

phayes0289's avatar

@Snapey I think that may be the problem I am having. All the CSS and login routes are being blocked by Ngrok.

Please or to participate in this conversation.