Laravel: 我们可以在以前的版本中使用最新版本的服务吗
Laravel: Can we use a service of latest version in previous version
我的应用程序是在 Laravel 5.1
开发的。我可以使用 Billing module of laravel from 5.2
吗?我在 5.2 中看到计费模块非常不同,需要不同的名称空间和接口。我尝试通过将 cashier package
升级到 ~6.0 来使用,但它产生了错误
Error Output: PHP Fatal error: Interface 'Laravel\Cashier\Contracts\Billable' not found in /project/app/Models/User.php on line 8
在 Laravel 5.1
和 cashier 4.0
中,
这就是我的用户模型具有以下名称空间的方式
<?php namespace App\Models;
use Cartalyst\Sentinel\Users\EloquentUser;
use Laravel\Cashier\Billable;
use Laravel\Cashier\Contracts\Billable as BillableContract;
class User extends EloquentUser implements BillableContract
{
use Billable;
/////
}
但是当我升级 cashier to ~6.0
时,它产生了上述错误。
我们可以在5.1中使用Laravel 5.2的收银台包吗,如果可以,我该怎么办?
根据图书馆的 composer.json
文件,Cashier 6.0 的依赖项不超过 Laravel 5.1 可以提供的要求,因此您应该能够将 Cashier 6.0 与 Laravel 5.1.这里的解决方法看起来很简单,去掉contract那一行即可:
use Laravel\Cashier\Contracts\Billable as BillableContract;
并且仅使用 Billable
特征:
use Laravel\Cashier\Billable;
这是因为虽然 Cashier 5.0 为 Laravel 5.2 提供了 Billable
接口 defined in Contracts
, version 6.0 removed that. Also the Cashier Documentation for Laravel 5.1 shows how to setup models with Cashier 5 by adding both use statements that you're currently using, while the Cashier Documentation,它使用 Cashier 6,但仅表明您需要使用 Billable
特性。
Cashier 4 和 6 依赖项之间还有一个显着差异:
- 需要收银员 4
"stripe/stripe-php": "~1.9"
- 收银员 6 需要
"stripe/stripe-php": "~3.0"
因此请确保该要求也得到满足。
我的应用程序是在 Laravel 5.1
开发的。我可以使用 Billing module of laravel from 5.2
吗?我在 5.2 中看到计费模块非常不同,需要不同的名称空间和接口。我尝试通过将 cashier package
升级到 ~6.0 来使用,但它产生了错误
Error Output: PHP Fatal error: Interface 'Laravel\Cashier\Contracts\Billable' not found in /project/app/Models/User.php on line 8
在 Laravel 5.1
和 cashier 4.0
中,
这就是我的用户模型具有以下名称空间的方式
<?php namespace App\Models;
use Cartalyst\Sentinel\Users\EloquentUser;
use Laravel\Cashier\Billable;
use Laravel\Cashier\Contracts\Billable as BillableContract;
class User extends EloquentUser implements BillableContract
{
use Billable;
/////
}
但是当我升级 cashier to ~6.0
时,它产生了上述错误。
我们可以在5.1中使用Laravel 5.2的收银台包吗,如果可以,我该怎么办?
根据图书馆的 composer.json
文件,Cashier 6.0 的依赖项不超过 Laravel 5.1 可以提供的要求,因此您应该能够将 Cashier 6.0 与 Laravel 5.1.这里的解决方法看起来很简单,去掉contract那一行即可:
use Laravel\Cashier\Contracts\Billable as BillableContract;
并且仅使用 Billable
特征:
use Laravel\Cashier\Billable;
这是因为虽然 Cashier 5.0 为 Laravel 5.2 提供了 Billable
接口 defined in Contracts
, version 6.0 removed that. Also the Cashier Documentation for Laravel 5.1 shows how to setup models with Cashier 5 by adding both use statements that you're currently using, while the Cashier Documentation,它使用 Cashier 6,但仅表明您需要使用 Billable
特性。
Cashier 4 和 6 依赖项之间还有一个显着差异:
- 需要收银员 4
"stripe/stripe-php": "~1.9"
- 收银员 6 需要
"stripe/stripe-php": "~3.0"
因此请确保该要求也得到满足。