admin管理员组

文章数量:1431419

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.

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.

Share Improve this question asked Apr 8, 2019 at 17:48 AmiritionAmirition 3555 silver badges20 bronze badges 1
  • 3 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 Commented Apr 9, 2019 at 22:55
Add a comment  | 

1 Answer 1

Reset to default 2

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.

本文标签: Use php libarary in wordpress plugins