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

Friday, May 20, 2022

[FIXED] How to include Composer within a GitHub repository

 May 20, 2022     composer-php, git, github, php, wordpress     No comments   

Issue

I am new to both Composer and Git/GitHub so please excuse me if this is a stupid question!

I have built a WordPress plugin which I have in a repository on GitHub and I will use the repository to distribute updates to the plugin using this plugin update checker library: https://github.com/YahnisElsts/plugin-update-checker

The plugin has a number of Composer dependencies that I have installed. I've been researching and apparently you aren't supposed to include the composer vendors directory in your GitHub repository (see here: https://getcomposer.org/doc/faqs/should-i-commit-the-dependencies-in-my-vendor-directory.md) however my confusion is how can I distribute the plugin from GitHub using the update checker if the vendors directory is not included?

What is the correct way to achieve this? Am I missing something obvious?

Thanks a lot in advance, Hayden


Solution

The rule of not committing the vendor folder makes sense in the case of a "composer-friendly" project, when running composer install is guaranteed by a build or release step and/or it is run manually during development.

I did not take a detailed look on the plugin-update-checker library you're using, but there are 2 cases:

  1. It only knows to fetch code from a branch - if this is the case, then you will have to commit the vendor folder, there are no other options.
  2. On the other hand, if it can handle getting the code from releases published on GitHub, then you can skip committing the vendor folder and only include it in your release builds. A pretty popular WordPress plugin does this, take a look on how they do it: https://github.com/Yoast/wordpress-seo. You will see that vendor is not committed, but if you download a release, it is there in the archive.


Answered By - Zoli Szabó
Answer Checked By - Candace Johnson (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