Cashier-stripe: [Composer] Ambiguous class resolution

Created on 2 Oct 2017  ·  8Comments  ·  Source: laravel/cashier-stripe

`Warning: Ambiguous class resolution, "Laravel\Cashier\Cashier" was found in both "/opt/lampp/htdocs/ugc/vendor/laravel/cashier-braintree/src/Cashier.php" and "/opt/lampp/htdocs/ugc/vendor/laravel/cashier/src/Cashier.php", the first will be used.

Warning: Ambiguous class resolution, "Laravel\Cashier\CashierServiceProvider" was found in both "/opt/lampp/htdocs/ugc/vendor/laravel/cashier-braintree/src/CashierServiceProvider.php" and "/opt/lampp/htdocs/ugc/vendor/laravel/cashier/src/CashierServiceProvider.php", the first will be used.

Warning: Ambiguous class resolution, "Laravel\Cashier\Billable" was found in both "/opt/lampp/htdocs/ugc/vendor/laravel/cashier-braintree/src/Billable.php" and "/opt/lampp/htdocs/ugc/vendor/laravel/cashier/src/Billable.php", the first will be used.

Warning: Ambiguous class resolution, "Laravel\Cashier\Subscription" was found in both "/opt/lampp/htdocs/ugc/vendor/laravel/cashier-braintree/src/Subscription.php" and "/opt/lampp/htdocs/ugc/vendor/laravel/cashier/src/Subscription.php", the first will be used.

Warning: Ambiguous class resolution, "Laravel\Cashier\Invoice" was found in both "/opt/lampp/htdocs/ugc/vendor/laravel/cashier-braintree/src/Invoice.php" and "/opt/lampp/htdocs/ugc/vendor/laravel/cashier/src/Invoice.php", the first will be used.

Warning: Ambiguous class resolution, "Laravel\Cashier\SubscriptionBuilder" was found in both "/opt/lampp/htdocs/ugc/vendor/laravel/cashier-braintree/src/SubscriptionBuilder.php" and "/opt/lampp/htdocs/ugc/vendor/laravel/cashier/src/SubscriptionBuilder.php", the first will be used.
Warning: Ambiguous class resolution, "Laravel\Cashier\Http\Controllers\WebhookController" was found in both "/opt/lampp/htdocs/ugc/vendor/laravel/cashier-braintree/src/Http/Controllers/WebhookController.php" and "/opt/lampp/htdocs/ugc/vendor/laravel/cashier/src/Http/Controllers/WebhookController.php", the first will be used.
`

How should I install both Stripe & Braintree together ?

Most helpful comment

@unckleg I ended up creating a console command that runs before composer autoload dumps and appends a sub-namespace to each of the composer packages. I now have two different namespaces:

Laravel\Cashier\Stripe;
Laravel\Cashier\Braintree;

Use it yourself:
https://gist.github.com/mirzabusatlic/494e592c29ec965d5428e9e226d6fdaf

All 8 comments

@unckleg - I don't actually think this is currently supported - or at least, I am curious why you need to do this!

It is possibly a Composer Issue - see: https://github.com/composer/composer/issues/4195

It is not "a Composer issue", the class map is invalid.

There are two "Cachier" classes under same namespace (directory/composer), and we should not agitating for why someone would use both packages.

This is the problem of the package that needs to be fixed.

+1 I'm trying to explore if it's possible to use Cashier (Stripe) & Cashier (Braintree) together. Running into the same namespace collision problem. I want to use Stripe for credit card processing but Braintree for it's PayPal integration only...

The only solution for this problem is to change the composer packages class map, and it's requires more in depth refactor process.

@unckleg I ended up creating a console command that runs before composer autoload dumps and appends a sub-namespace to each of the composer packages. I now have two different namespaces:

Laravel\Cashier\Stripe;
Laravel\Cashier\Braintree;

Use it yourself:
https://gist.github.com/mirzabusatlic/494e592c29ec965d5428e9e226d6fdaf

Hi @mirzabusatlic! Thank you for script. Can you please clarify how to use it properly? I use it in my User model in following way:
`

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Cashier\Stripe;
use Laravel\Cashier\Braintree;

class User extends Authenticatable
{
use Notifiable;
use Stripe\Billable;
use Braintree\Billable;
...`

And get this:
TRAIT METHOD CHARGE HAS NOT BEEN APPLIED, BECAUSE THERE ARE COLLISIONS WITH OTHER TRAIT METHODS ON APP\USER

Thanks in advance

Heya, we just enabled issues for the Braintree repo. If this is still an issue can you report the issue there? Thanks! https://github.com/laravel/cashier-braintree/issues

仔细看看你Ambiguous class resolution报的文件路径在哪儿,看用的上吧,用不上就删了吧

Was this page helpful?
0 / 5 - 0 ratings