OctoberCMSには新着ですが、私にはについての普通の知識があります.LaravelOctobercmsでミドルウェアを作成する方法
Laravelでは、ミドルウェアを作成し、複数のミドルウェアをグループ化するのは簡単です。
10CMSでは、適切なガイドラインや満足できる回答がまだ見つかりません。
誰でもミドルウェアを作成し、10月中に複数のミドルウェアをグループ化する方法を知っていますか?あなたのプラグインフォルダに
OctoberCMSには新着ですが、私にはについての普通の知識があります.LaravelOctobercmsでミドルウェアを作成する方法
Laravelでは、ミドルウェアを作成し、複数のミドルウェアをグループ化するのは簡単です。
10CMSでは、適切なガイドラインや満足できる回答がまだ見つかりません。
誰でもミドルウェアを作成し、10月中に複数のミドルウェアをグループ化する方法を知っていますか?あなたのプラグインフォルダに
、あなたがこのようなブート機能に宣言する必要があり あなたのミドルウェアを設定するには、ファイルPlugin.phpを使用します。
public function boot()
{
// Register middleware
$this->app['Illuminate\Contracts\Http\Kernel']
->pushMiddleware('Experty\Experts\Middleware\ExpertsMiddleware');
}
とExpertsMiddleware.php
に<?php namespace Experty\Experts\Middleware;
use Closure;
use Illuminate\Foundation\Application;
use Illuminate\Contracts\Routing\Middleware;
use Illuminate\Http\Response;
use October\Rain\Exception\AjaxException;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
class ExpertsMiddleware implements Middleware
{
/**
* The Laravel Application
*
* @var Application
*/
protected $app;
/**
* Create a new middleware instance.
*
* @param Application $app
* @return void
*/
public function __construct(Application $app)
{
$this->app = $app;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
//youre code
}
}
ありがとう@ tahaazzabi –
_ " Illuminate \ Contracts \ Routing \ Middlewar電子契約はLaravel 5.2 "_ https://stackoverflow.com/a/35487715/69537で推奨されていません – Meysam
ここにありますリンクはこれがあなたを助けることができるhttps://octobercms.com/forum/post/how-to-enable-cors –
@DCoderは多くの役に立つが、あなたの時間のために感謝を見つけることができません:) –