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

Monday, January 31, 2022

[FIXED] Composer installs TCPDF with .git repository

 January 31, 2022     composer-php, git, tcpdf     No comments   

Issue

I am trying to install TCPDF via composer. It works, but unfortunately, it always installs also whole .git directory which has 93 MB. I only want to install TCPDF files without .git stuff.

How to do that?

Here's my composer.json:

{
    "name": "myprojects/project1",
    "require": {
        "yiisoft/yii": "~1.1.15",
        "twbs/bootstrap": "~3.2.0",
        "tecnick.com/tcpdf": "~6.0.89",
        "phpoffice/phpexcel": "~1.8.0"
    }
}

Thank you in advance.

EDIT 1:

Following is the composer configuration in the TCPDF composer file downloaded from packagist repo - not sure if this might help solving the issue:

{
    "name": "tecnick.com/tcpdf",
    "version": "6.0.089",
    "homepage": "http://www.tcpdf.org/",
    "type": "library",
    "description": "TCPDF is a PHP class for generating PDF documents.",
    "keywords": ["PDF","tcpdf","PDFD32000-2008","qrcode","datamatrix","pdf417","barcodes"],
    "license": "LGPLv3",
    "authors": [
    {
        "name": "Nicola Asuni",
        "email": "info@tecnick.com",
        "homepage": "http://nicolaasuni.tecnick.com"
    }
    ],
    "require": {
        "php": ">=5.3.0"
    },
    "autoload": {
        "classmap": [
        "fonts",
        "config",
        "include",
        "tcpdf.php",
        "tcpdf_parser.php",
        "tcpdf_import.php",
        "tcpdf_barcodes_1d.php",
        "tcpdf_barcodes_2d.php",
        "include/tcpdf_colors.php",
        "include/tcpdf_filters.php",
        "include/tcpdf_font_data.php",
        "include/tcpdf_fonts.php",
        "include/tcpdf_images.php",
        "include/tcpdf_static.php",
        "include/barcodes/datamatrix.php",
        "include/barcodes/pdf417.php",
        "include/barcodes/qrcode.php"
        ]
    }
}

EDIT 2:

I have changed composer config as follows by adding config option "preferred-install" : "dist", but did not help. I also tried "dev-master", still the same... :-(

{
    "name": "myprojects/project1",
    "config": {
        "preferred-install" : "dist"
    },
    "require": {
        "yiisoft/yii": "~1.1.15",
        "twbs/bootstrap": "~3.2.0",
        "tecnick.com/tcpdf": "~6.0@stable",
        "phpoffice/phpexcel": "~1.8.0"
    }
}

Solution

General advice for avoiding clones

If you get the whole directory it must be either because you set --prefer-source when installing, or you have a preferred-install config value set to source, or you install the dev-master package, in which case Composer defaults to using the source install (git clone).

The solution depends on the exact situation, and you did not give enough details to say which is the right one, but you can most likely fix it with either of these:

  • set --prefer-dist when installing
  • use composer config preferred-install dist to set the flag permanently
  • make sure you install only tagged releases by requiring "tecnick.com/tcpdf": "~6.0@stable", then it should always pick the dist package by default.

Special case for packages not hosted on github or bitbucket:

https://packagist.org/packages/tecnick.com/tcpdf is actually hosted on sourceforge, which does not support automatic zip building from any git revision. As such packagist can at the moment not provide you with zips and so composer has to clone the repo.

The only solution for now is to get the maintainer to move the package to github, if only as a readonly-mirror.

https://github.com/tcpdf-clone/tcpdf exists but I don't know if it's officially maintained or not. If yes or if it's trusted at least then it would be an option to change the packagist url for the tcpdf package to be that github one.



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