Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Tyler Longren:
Use Composer in Your WordPress Plugin or Theme
Nov 16, 2015 @ 16:22:47

In this post to his site Tyler Longren shows how to use Composer to install WordPress plugins as well as the usual libraries.

I love Composer. It just makes including libraries or scripts in your app incredibly easy. So easy that it’s stupid not to use it (in many, if not most cases).

[...] I'd never used Composer with a proprietary WordPress plugin before. The plugin is for a client so it’ll never be available to the public. Here’s the steps I took to make this WordPress plugin compatible with Composer so that I can easily bring in third-party libraries.

He breaks it down into a five step process, showing the installation of the Mailgun PHP client:

  • Install composer on your server
  • Add Mailgun as a dependency
  • Check your composer.json file
  • Tell composer to install Mailgun
  • Autoload Our Mailgun Classes in Our Plugin

With the help of Composer, the Mailgun client is ready to go and accessible in his WordPress instance, quickly and easily.

tagged: composer wordpress plugin mailgun client install autoload

Link: https://longren.io/use-composer-in-your-wordpress-plugin-or-theme/


Trending Topics: