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.

  • 2
    You can include these in your plugin however you see fit, but the final outcome will need to be the full plugin files. WordPress does not support composer installs and you cannot rely on that library being available. – MikeNGarrett Apr 9 '19 at 22:55

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.