morrislaptop/laravel-five-package-bridges

在 Laravel 5 中使用 Laravel 4 包

1.0.3 2015-03-02 21:50 UTC

This package is auto-updated.

Last update: 2024-08-26 03:33:40 UTC


README

Build Status

这个 Laravel 包提供了一个桥梁特质和多个桥梁,允许 Laravel 4 包在 Laravel 5 中使用。

当前已桥梁的包有

如果你想要构建一个桥梁,请遵循贡献指南

安装

首先通过 Composer 安装此包。

composer require morrislaptop/laravel-five-package-bridges

此操作完成后,添加配置服务提供者,这会将 package() 方法带回配置存储库。打开 app/config/app.php 并添加..

'Morrislaptop\LaravelFivePackageBridges\ConfigServiceProvider',

然后我们需要用桥梁替换核心 Application 类,这会添加各种方法如 after() 等。打开 bootstrap/app.php 并替换..

$app = new Illuminate\Foundation\Application(
    realpath(__DIR__.'/../')
);

$app = new Morrislaptop\LaravelFivePackageBridges\Application(
    realpath(__DIR__.'/../')
);

最后一步是将桥梁服务提供者添加到原始服务提供者中。

打开 app/config/app.php,并添加适当的行。

'Morrislaptop\LaravelFivePackageBridges\Bridges\FlashServiceProvider',

'Morrislaptop\LaravelFivePackageBridges\Bridges\GeneratorsServiceProvider',
'Morrislaptop\LaravelFivePackageBridges\Bridges\ImageServiceProvider',
'Morrislaptop\LaravelFivePackageBridges\Bridges\ExcelServiceProvider',
'Morrislaptop\LaravelFivePackageBridges\Bridges\ClockworkServiceProvider',
'Morrislaptop\LaravelFivePackageBridges\Bridges\SentryServiceProvider',

就这样!这些包现在就像在 Laravel 4 中一样正常工作了。

自定义包

如果你有一个私有包,你可以简单地创建自己的桥梁服务提供者,并从该包中引入特质。

<?php namespace App\Bridges;



use Morrislaptop\LaravelFivePackageBridges\LaravelFivePackageBridgeTrait;

use Acme\Private\NuclearServiceProvider as BaseNuclearServiceProvider;



class NuclearServiceProvider extends BaseNuclearServiceProvider 
{


	use LaravelFivePackageBridgeTrait;


}

贡献

请参阅贡献指南