Using a git repo as a composer repository

Written by James McDonald

December 23, 2019

In CakePHP variable visibility is generally defined using this standard:

public $defaultConfig;
protected $_defaultConfig;
private $__defaultConfig;

Just had a situation where I had extended a class and one variable from the base class was marked as public. My VSCode editor running phpfmt with the CakePHP Coding Style enabled kept on reformatting the public variable to remove the underscore in the name.

As I can’t figure out how to turn off phpfmt’s adding and removing underscores behaviour while still keeping the CakePHP Coding style I needed to modify the original package in my own forked git repo and then point composer to the modified repository

Using a git repo as a composer repository

So here is the link so I don’t forget it

https://getcomposer.org/doc/05-repositories.md#vcs

You need to have a branch in your modified repository that matches something from the origin repo (https://github.com/Holt59/cakephp3-bootstrap-helpers) prepended with dev- so their branch is 4.0.1-alpha

So I made changes to my repo in the 4.0.1-alpha branch and then committed the changes, created a branch named dev-4.0.1-alpha using git checkout -b dev-4.0.1-alpha and pushed it up to my repo at https://github.com/jmcd73/cakephp3-bootstrap-helpers

Then add your tweaked repo’s URL into your composer.json in the repositories key and change the version on the original repo name to your dev-* version:

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/jmcd73/cakephp3-bootstrap-helpers"
    }
  ],
  "require": {
    "php": ">=5.5.9",
    "cakephp/cakephp": "~3.2",
    "mobiledetect/mobiledetectlib": "2.*",
    "cakephp/migrations": "~1.0",
    "cakephp/plugin-installer": "*",
    "twbs/bootstrap": "^4.0.0",
    "holt59/cakephp3-bootstrap-helpers": "dev-4.0.1-alpha"
  }
}

Refs:

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

You May Also Like…

Toggen builds a new website

So I have built and hosted a new website for Roger Clark Pest Management they are a family owned and operated Pest...

WizTree

Just downloaded WizTree (not a sponsor) from https://wiztreefree.com/ It seems to do what it says on the tin which is...

Scam call from “Telstra”

Just had a call from a man with a sub-continental accent from caller ID 0734946596 Told me there was problem with my...