I need to work with excel files in my wordpress plugin and I should use the PhpSpreadsheet
library. The problem is I don’t know how to import this library in my plugin? Should I use autoload or composer? Since this plugin is for a customer, it’s better to be a way the requires least modification to the site itself.
1 Answer
You can always use the Composer when making a plugin and require all its dependencies. But as MikenGarrett said, finally you have to bundle all the required vendors into the plugin as a whole package.
There are WordPress repository, containing /vendor/
directory1 and their development environment containing composer.json
file declaring production-dependencies ('require'
)2.
But using Composer you will get a /vendor/
directory and vendor directory is excluded while scraping strings for translation in WordPress plugin repository. Some people suggest changing the name of the /vendor/
directory into something else like /packages/
to scrape their strings too.
Thanks to Pascal Birchler, Tor-Björn Fjellner, Aristeides Stathopoulos for assisting in this matter.