Dependency management

You have multiple PHP libraries, frameworks, components, and tools available to use in your project. Until a few years ago, PHP did not have a modern way of managing project dependencies. At this moment we have Composer, a flexible project that was converted into the de facto standard of dependency management.

You are probably familiar with Composer as we were using this tool all over the book to install new libraries in the vendor folder. At this point, you will be wondering whether you should commit the dependencies of your vendor folder. There is no quick response, but the general recommendation is no, you should not commit the vendor folder to your repository.

The main disadvantages of committing the vendor folder can be summarized as follows:

  • Increases the size of your repository
  • Duplicates the history of your dependencies

As we told you before, not committing the vendor is the main recommendation, but if you really need to do it, here are some suggestions:

  • Use tagged releases (no dev versions) so that Composer fetches zipped sources
  • Use the --prefer-dist flag or set preferred-install to dist in your config file
  • Add the /vendor/**/.git rule to your .gitignore file
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.33.157