Comments (7)
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.
from strauss.
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.
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.
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.
@BrianHenryIE extra_files
or additional_files
seems fine to me.
from strauss.
@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)
- Namespaces of static methods not replaced inside array square brackets
- Fails with autoload psr-4 key with array as entry
- Workflows are referencing vulnerable actions HOT 1
- Deprecated: Return type of MyCLabs\Enum\Enum::jsonSerialize() should... HOT 4
- Fatal error: Uncaught Error: Class "BrianHenryIE\Strauss\Console\Application" not found HOT 4
- Error on call to undefined WP function HOT 2
- Problem with package name `"Blockchain/Blockchain"` HOT 1
- Unprefixed static function call in ternary operation
- Double namespacing issue when using nested namespace prefix HOT 1
- #[\ReturnTypeWillChange] becomes #[\MY_CUSTOM_PREFIX_ReturnTypeWillChange]
- Local symlinked repositories fail HOT 2
- Not prefixing all classes? HOT 3
- Incorrect binary name when installed using composer HOT 2
- Good idea to set `target_directory`to 'vendor'? HOT 1
- Feature: Change WordPress translation domain HOT 1
- Still works? HOT 3
- Add warning about using composer packages installed with symlink HOT 3
- Issue bundling AWS S3 package HOT 3
- Troubles Namespacing WPGraphQL HOT 5
- `exclude_from_copy` does not apply to `files` autoloaders
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from strauss.