PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, May 11, 2022

[FIXED] Why is Symfony/Git ignoring some of the folders?

 May 11, 2022     git, gitignore, symfony     No comments   

Issue

I just noticed that when I push my Symfony project to Gitlab, some of the folders (for example "vendor") are not pushed (because they are ignored by .gitignore).

Why is this? And isn't it problematic if I then want to clone the project from Gitlab onto my other computer, where I then would be missing the vendor folder?


Solution

Typically you don't want to include the vendor folder in git, as that can be rebuilt when you deploy by saving your composer.lock file.

Your deploy should use composer install to build the vendor directory, and it will use the same files as those installed by composer in your source commit(s).

In summary:

  • When changing packages via modifications to the composer.json, run composer update.
  • Save/commit changes to composer.lock
  • clones of the repo should run composer install
  • composer does more than just fetch and install dependencies -- it also runs utility scripts, and differentiates between production and development environments. It will also build the autoload script for inclusion in your project.
  • Running composer install can be done whenever you would like, so you can run it everytime you git pull if you want. It should be idempotent with git repos.
  • For a production environment there are options to consider like using the --no-dev flag. composer install --no-dev This will omit any development libraries, however, it is important to have a staging environment to insure you've actually tested that build somewhere. You might want to research and consider these additional options for a production deployment: composer install --no-dev --no-scripts --optimize-autoloader.


Answered By - gview
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing