DEV Community

Cover image for Enhance Team Collaboration with Laravel Sail Share Command
Timilehin Olusegun
Timilehin Olusegun

Posted on

Enhance Team Collaboration with Laravel Sail Share Command

Have you ever found yourself in a situation where you've completed a local project, but your team is waiting for it to be deployed to the staging server before they can start working on it? That's what happened to me when I added a new feature to an API at work. I created a pull request, but it took too long to be approved and merged. That's when my teammate asked me to "share it." I was taken aback because I had no idea what he meant. But little did I know that sharing local projects online was much easier than I thought.

In this article, I'm going to guide you through sharing your local Laravel projects online for anyone to access, just like my teammate showed me.

Prerequisites

Before we dive into the steps to share your local Laravel project, there are some conditions to be met:

  1. A basic understanding of the Laravel framework and its components.
  2. Installed Laravel Sail: To use the Laravel Sail Share Command, the reader should have Laravel Sail installed on their Laravel project. You can follow the instructions on the Laravel Sail documentation page to install Laravel Sail on your machine.
  3. Docker: You need to have Docker installed on your local machine.
  4. A Local Laravel Project that you want to share. Access to the terminal or command line as the Laravel Sail Share Command is executed through the terminal or command line.

An idea of containerisation and how Docker works is a good nice-to-have, but it’s not compulsory for this article. These prerequisites will ensure you have the necessary setup to follow along with the steps outlined in the article.

What is Laravel Sail?

Laravel Sail is a simple command-line interface that gives you access to Laravel's built-in Docker development environment. It is a great way to set up and start building your Laravel application using PHP, MySQL, and Redis without prior Docker experience. With Laravel Sail, developers can set up their Laravel development environment quickly and easily without worrying about the underlying infrastructure and dependencies.

Additionally, Laravel Sail provides some useful commands for managing your Laravel project, such as starting and stopping the development environment, running database migrations, and sharing your project online with others.

Using the Laravel Sail Share Command

First, you must launch your project by running the sail up command. This command will start all the Docker containers defined in your application's docker-compose.yml file (so you need to have Docker running on your machine). You can also run the sail up -d to start the containers in the background.

Once the containers are up and running, you can share your local Laravel project using the Laravel Sail Share command. This command to share your local Laravel project is



sail share


Enter fullscreen mode Exit fullscreen mode

This command will create a publicly accessible URL that your team can use to access your local Laravel project. You will get something similar to the image shown below.

Image description

Now you can send the URL to the members of your team. The generated URL will allow them to access your local Laravel project anywhere, at any time.

Please note that to share your project using the share command, you must configure the trusted proxies within the TrustProxies middleware. It helps URL generation helpers like URL and route to figure out which HTTP host to use for URL generation.



    /**
     * The trusted proxies for this application.
     *
     * @var array|string|null
     */
    protected $proxies = "*";



Enter fullscreen mode Exit fullscreen mode

The share command uses an open-source tunnelling service called Expose. Expose is built by BeyondCode. The sail share command runs Expose under the hood.

Conclusion

Thanks to the Laravel Sail share command, sharing your local Laravel project with others is easy. It can help to demonstrate your work, get feedback, or collaborate with others. Just remember to stop sharing your project by using the sail down command.

A different situation where sharing your local project can be helpful is if you are developing a mobile application and want to test it with the API on your local machine. Personally, having this knowledge would have made my life easier years ago.

In this article, we have looked at how to share your local Laravel projects with your team using the Laravel Sail Share Command. Using these steps, you can enhance your team’s collaboration and make it easy to access your local Laravel projects. With the Laravel Sail Share Command, you can improve team communication and make sure that your team can function more effectively and efficiently.

Further Reading

Top comments (0)