Giter VIP home page Giter VIP logo

Comments (7)

BrianHenryIE avatar BrianHenryIE commented on August 22, 2024 3

You can use override_autoload to add a files key to the package's existing autoload configuration with the extra files you want.

Adding the res folder to composer/ca-bundle is straightforward:

{
  "require": {
    "composer/ca-bundle": "1.2.10"
  },
  "require-dev": {
    "brianhenryie/strauss": "0.10.4"
  },
  "extra": {
    "strauss": {
      "target_directory": "strauss",
      "namespace_prefix": "Issue31\\",
      "override_autoload": {
        "composer/ca-bundle": {
            "psr-4": {
              "Composer\\CaBundle\\": "src"
            },
            "files": [
              "res"
            ]
        }
      }
    }
  }
}

tecnickcom/tcpdf's fonts folder contains PHP files that you probably don't want to prefix, so add that path to the exclude_from_prefix/file_patterns key.

{
  "require": {
    "tecnickcom/tcpdf": "6.4.2"
  },
  "require-dev": {
    "brianhenryie/strauss": "0.10.4"
  },
  "extra": {
    "strauss": {
      "target_directory": "strauss",
      "namespace_prefix": "Issue31\\",
      "override_autoload": {
        "tecnickcom/tcpdf": {
          "classmap": [
            "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"
          ],
          "files": [
            "fonts"
          ]
        }
      },
      "exclude_from_prefix": {
        "file_patterns": [
          "/^psr.*$/",
          "~^tecnickcom/tcpdf/fonts.*~"
        ]
      }
    }
  }
}

TBH, most of the classmap they have defined is unnecessary here. Once the directory is specified, everything inside it will be copied.

I'll leave this open until I update the README with a few lines about this.

from strauss.

Spreeuw avatar Spreeuw commented on August 22, 2024 1

@alexmigf

from strauss.

Spreeuw avatar Spreeuw commented on August 22, 2024

Thanks for working that out! I think we'll stick to copying afterwards in that case, for simplicity sake. Configuring the autoloader part feels like an unnecessary extra step if all you want is the files to be copied.

from strauss.

rickmacgillis avatar rickmacgillis commented on August 22, 2024

Excellent. This worked well for copying directories I need. Thank you @BrianHenryIE.

Stripped down version:

"extra": {
    "strauss": {
      "override_autoload": {
        "composer/ca-bundle": {
            "files": [
              "res"
            ]
        }
      }
    }
  }

from strauss.

BrianHenryIE avatar BrianHenryIE commented on August 22, 2024

I'm considering this functionality, maybe like:

"extra": {
    "strauss": {
      "copy_files": {
        "composer/ca-bundle": [
            "res"
          ]
      }
    }
  }

It would really just be merged back into the override_autoload key mentioned above, but it's a little clearer.

What's the best name? extra_files, include_files, additional_files, just files?

from strauss.

alexmigf avatar alexmigf commented on August 22, 2024

@BrianHenryIE extra_files or additional_files seems fine to me.

from strauss.

UVLabs avatar UVLabs commented on August 22, 2024

@BrianHenryIE I had need for something like this due to how Dompdf works. By default strauss does not copy some of the root files. The VERSION file is actually needed by dompdf or else it throws an error when using the library.

See this line: https://github.com/dompdf/dompdf/blob/v2.0.3/src/Dompdf.php#L261

I had to the following to get all the files into the prefixed directory:

"override_autoload": {
 "dompdf/dompdf": {
  "classmap": ["."]
 }
}

from strauss.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.