Laravel Sail after cloning from Git repository
Asked Answered
H

3

12

I currently have my own Laravel application running on Docker using Laravel sail on Windows 11 using Ubuntu on WSL2. This works fine and as intended. I've pushed my work onto a Git repository, but how would I be able to pull this onto a new system? The vendor files that come with Laravel sail when you install won't be sent to the repository, so sail will be useless until composer's vendors files are installed.

I'm new to Docker, would this mean I would have to install composer and PHP on Linux (WSL2) and then install the vendor files? Is there any easier method to this, or is this the conventional way?

Thank you for any help.

Handful answered 7/2, 2022 at 21:11 Comment(3)
getcomposer.org/doc/faqs/…Houseraising
Does this answer your question? How to commit Composer vendor folder into Git repository?Houseraising
Committing dependencies is just a cop-out for managing dependencies responsibly. It's almost never a good idea.. especially when there's other ways to solve the problem like there is here.Paddy
P
13

I've handled this by using the composer docker image to install the dependencies.

Clone the repo and then run the following command from within the root directory.

docker run --rm --interactive --tty -v $(pwd):/app composer install

By mounting your repository into the container, the composer container will write the vendor directory and it will appear in your host.

Paddy answered 7/2, 2022 at 21:19 Comment(3)
running this command causes message "Your lock file does not contain a compatible set of packages. Please run composer update." What have we do in this case?Cosentino
@andrew There's probably an explanation of why the packages are not resolvable (it's usually several lines and takes some time or experience to determine the root cause). Assuming the packages were resolvable prior to this, my guess would be that it's a conflict with the composer version of PHP verses the version your packages require. I don't have a quick solution here, but hopefully that gives you the right direction to start downPaddy
Actually I would try out robesantoro's answer. I think it accounts for the php version mismatchesPaddy
B
10

The Laravel Sail docs says:

docker run --rm \
    -u "$(id -u):$(id -g)" \
    -v $(pwd):/var/www/html \
    -w /var/www/html \
    laravelsail/php81-composer:latest \
    composer install --ignore-platform-reqs

Anyway the simpler composer docker image solution seems to work..

Bogan answered 28/4, 2022 at 20:38 Comment(1)
first used Brian's method but was having composer permission issues. So had to remove vendor folder and run this command.Kob
P
0

steps:

  1. Make sure Docker is running on your machine.

  2. go to your project folder

  3. connect to the wsl with wsl -d ubuntu

  4. run the following command (you can select the version of php here; I used 8.2)

    docker run --rm \ -u "$(id -u):$(id -g)" \ -v "$(pwd)":/opt \
    -w /opt \    laravelsail/php82-composer:latest \
    composer install --ignore-platform-reqs
    
  5. Wait for the installation

  6. Then start the server with ./vendor/bin/sail up -d

Picturize answered 28/8, 2023 at 9:5 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.