'How to setup and run laravel, from git?

Either I miss something, or the whole chain lacks something.

Here's my assumption:

The whole point of containerization in development, is to reduce the cost of environment setup, and create a prepared image with all the required pieces.

So, when I read that Laravel Sail is installing laravel via containerization, I get excited. Thus I install it via their instructions, and everything works.

Then the problem begins. Because:

  • After a successful installation, I create a git repo, with GitHub's default laravel .gitignore
  • Then I push the newly installed laravel app into my git repo.
  • Then I ask a developer to start developing it. Please note that:
    • He does not have PHP installed
    • He does not have Composer installed
  • He clonse the repo, and as per installation guide, runs ./vendor/bin/sail up
  • But ./vender folder is correctly excluded in .gitignore
  • Thus his command results in:

bash: ./vendor/bin/sail: No such file or directory

  • He Googles it of course, and finds out that people suggest to run composer update
  • He goes to install composer, then before that PHP, then all extensoins of PHP, then ...

Do I miss something here? The whole point of containerization was to not install the required environment locally.

What is the proper way of running a laravel app, that is not installed from https://laravel.build, but is cloned from a git repo, WITHOUT having PHP or Composer installed locally?

Update

I found Bitnami laravel docker and it's exactly what containers should be.



Solution 1:[1]

You are right and the other developer doesn't need to have php nor composer installed. All he/she needs is Docker installed on the local machine.

If you scaffolded the project with what is mentioned in the official Laravel docs under the Getting started section, then you will have a docker-compose.yml file in your project root directory.

For Windows

For Linux

For Mac OS

All the developer has to do after git cloning the repository is to run

docker-compose up --build -d

That's it.

Solution 2:[2]

For those struggling with this issue... I've found a command that work perfectly fine.

First of all, you don't need to locally have any PHP or Composer installed, maybe there is a misunderstanding about it, all you need is Docker.

Docker will install everything you need in something I understand is like a sandbox, not locally, for each project.

And for those downloaded projects, from GIT as example, that does not have vendor folder, and obviously cannot execute sail up you can simple execute:

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

That commando will download a composer image for docker, if you do not have one yet. Then, will run a composer install and you are free to execute a sail up.

That's all.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 r4pt0s
Solution 2 Noob Dev