I've already developed several composer modules which I've published successfully to packagist.
All of them are fully class based, and I know how the autoloading process works for those - if multiple projects use my packagist module, they will be included only once.
Does it work the same for files?
I want to develop a packagist module for "missing" WordPress functions - i.e. functions I regularly use across all of my projects.
If multiple projects include that packagist module, will I get errors about multiple definitions of the same function in a same namespace?
Clarification.
I'm creating a composer module sgi/wp-utils. It won't have classes. It will only include files. Like this
{
"autoload": {
"files": [
"src/Assets/functions.php",
"src/Posts/functions.php"
]
}
}
It will be used to define utility functions I plan to use across many projects (plugins, themes).
If multiple plugins / themes use the same package, will composer load files only once per WP installation, or I need to wrap functions with function_exists()
calls?