How to use GuzzleHttp in a plugin without causing conflicts?

[ad_1]

I have a composer.json file that looks like this:

{
“require”: {
“google/analytics-data”: “^0.9.3”,
“google/cloud”: “^0.196.0”
}
}

The created vendor directory gets moved to /usr/lib/plugin-name so that it can be used by multiple sites. It gets loaded by the plugin file like this:

<?php
/**
* @package PluginName
*/

namespace PluginName;

if (wp_get_environment_type() === ‘development’) {
if (file_exists(dirname(__FILE__) . ‘/vendor/autoload.php’)) {
require_once dirname(__FILE__) . ‘/vendor/autoload.php’;
}
} else {
if (file_exists(‘/usr/lib/plugin-name/autoload.php’)) {
require_once ‘/usr/lib/plugin-name/autoload.php’;
}
}

However I get conflicts when there is another active package that uses guzzle.

When I research this issue, it appears that I need to prefix the vendor directory but every search gets SEO hijacked by php-prefixer, a paid service. How am I actually supposed to have two plugins that use Guzzle?

Thanks for any help!

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer