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

Thursday, January 20, 2022

[FIXED] how to use a substitute repository for a dependency's dependency in Composer?

 January 20, 2022     composer-php, html2pdf, php, tcpdf     No comments   

Issue

this is my composer.json:

{
    "require": {
        "spipu/html2pdf": "dev-master"
    }
}

now, spipu/html2pdf depends on tecnickcom/TCPDF, but i would like to use the patch-1 branch of divinity76/TCPDF as a substitute for tecnickcom/TCPDF, how can i do that?

(here's the problem: there's a unicode bug? limitation? in tecnickcom/TCPDF , making it impossible to generate PDF files with unicode filenames, like aæøå.pdf. i have sent a fix pull request , but it's been over 2 months with no response from the upstream maintainer :( i tried emailing tecnickcom too, but no response )


Solution

with the link posted by Axalix in a comment, i found out i could substitute 1 repository with another, with the repositories property in composer.json , however, this substitute repository will not load tags that don't already exist in the original repository, just branches. however, spipu/html2pdf specifically requires version ~6.2, which makes composer refuse to install any dev-branch... but with the as keyword, i can substitute any branch with any version too, with that in mind, this seems to work:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/divinity76/TCPDF.git"
        }
    ],
    "require": {
        "spipu/html2pdf": "dev-master",
        "tecnickcom/tcpdf": "dev-patch-1 as 6.2.13"
    }
}

i found the branch-version substitution solution (the as keyword) here http://mnapoli.fr/overriding-dependencies-with-composer/

and the repository substitution solution in this answer: https://stackoverflow.com/a/13500676/1067003 (linked to by Axalix )



Answered By - hanshenrik
  • 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