Chapter 04

処理フロー

ta.toshio
ta.toshio
2021.04.22に更新

管理側商品一覧 - catalog.product.index - の処理の流れ

raw

ProductController.php:104, AvoRed\Framework\Catalog\Controllers\ProductController->index()
ControllerDispatcher.php:48, Illuminate\Routing\ControllerDispatcher->dispatch()
Route.php:219, Illuminate\Routing\Route->runController()
Route.php:176, Illuminate\Routing\Route->run()
Router.php:681, Illuminate\Routing\Router->Illuminate\Routing\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php:679-683}()
Pipeline.php:130, Illuminate\Routing\Pipeline->Illuminate\Pipeline\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:128-136}()
Permission.php:24, AvoRed\Framework\Support\Middleware\Permission->handle()
Pipeline.php:171, Illuminate\Routing\Pipeline->Illuminate\Pipeline\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:147-180}()
Authenticate.php:43, AvoRed\Framework\Support\Middleware\AdminAuth->handle()
Pipeline.php:171, Illuminate\Routing\Pipeline->Illuminate\Pipeline\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:147-180}()
AvoRedCore.php:36, AvoRed\Framework\Support\Middleware\AvoRedCore->handle()
Pipeline.php:171, Illuminate\Routing\Pipeline->Illuminate\Pipeline\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:147-180}()
SubstituteBindings.php:41, Illuminate\Routing\Middleware\SubstituteBindings->handle()
Pipeline.php:171, Illuminate\Routing\Pipeline->Illuminate\Pipeline\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:147-180}()
VerifyCsrfToken.php:78, App\Http\Middleware\VerifyCsrfToken->handle()
Pipeline.php:171, Illuminate\Routing\Pipeline->Illuminate\Pipeline\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:147-180}()
ShareErrorsFromSession.php:49, Illuminate\View\Middleware\ShareErrorsFromSession->handle()
Pipeline.php:171, Illuminate\Routing\Pipeline->Illuminate\Pipeline\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:147-180}()
StartSession.php:56, Illuminate\Session\Middleware\StartSession->handle()
Pipeline.php:171, Illuminate\Routing\Pipeline->Illuminate\Pipeline\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:147-180}()
AddQueuedCookiesToResponse.php:37, Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle()
Pipeline.php:171, Illuminate\Routing\Pipeline->Illuminate\Pipeline\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:147-180}()
EncryptCookies.php:67, App\Http\Middleware\EncryptCookies->handle()
Pipeline.php:171, Illuminate\Routing\Pipeline->Illuminate\Pipeline\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:147-180}()
Pipeline.php:105, Illuminate\Routing\Pipeline->then()
Router.php:683, Illuminate\Routing\Router->runRouteWithinStack()
Router.php:658, Illuminate\Routing\Router->runRoute()
Router.php:624, Illuminate\Routing\Router->dispatchToRoute()
Router.php:613, Illuminate\Routing\Router->dispatch()
Kernel.php:170, App\Http\Kernel->Illuminate\Foundation\Http\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:167-171}()
Pipeline.php:130, Illuminate\Routing\Pipeline->Illuminate\Pipeline\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:128-136}()
InjectDebugbar.php:67, Barryvdh\Debugbar\Middleware\InjectDebugbar->handle()
Pipeline.php:171, Illuminate\Routing\Pipeline->Illuminate\Pipeline\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:147-180}()
TrustProxies.php:57, App\Http\Middleware\TrustProxies->handle()
Pipeline.php:171, Illuminate\Routing\Pipeline->Illuminate\Pipeline\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:147-180}()
TransformsRequest.php:21, Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle()
Pipeline.php:171, Illuminate\Routing\Pipeline->Illuminate\Pipeline\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:147-180}()
TransformsRequest.php:21, App\Http\Middleware\TrimStrings->handle()
Pipeline.php:171, Illuminate\Routing\Pipeline->Illuminate\Pipeline\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:147-180}()
ValidatePostSize.php:27, Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle()
Pipeline.php:171, Illuminate\Routing\Pipeline->Illuminate\Pipeline\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:147-180}()
CheckForMaintenanceMode.php:63, App\Http\Middleware\CheckForMaintenanceMode->handle()
Pipeline.php:171, Illuminate\Routing\Pipeline->Illuminate\Pipeline\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:147-180}()
Pipeline.php:105, Illuminate\Routing\Pipeline->then()
Kernel.php:145, App\Http\Kernel->sendRequestThroughRouter()
Kernel.php:110, App\Http\Kernel->handle()
index.php:55, {main}()

整形

  • piplelineを削除した
ProductController.php:104, AvoRed\Framework\Catalog\Controllers\ProductController->index()
ControllerDispatcher.php:48, Illuminate\Routing\ControllerDispatcher->dispatch()
Route.php:219, Illuminate\Routing\Route->runController()
Route.php:176, Illuminate\Routing\Route->run()
Router.php:681, Illuminate\Routing\Router->Illuminate\Routing\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Routing/Router.php:679-683}()
Pipeline.php:130, Illuminate\Routing\Pipeline->Illuminate\Pipeline\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:128-136}()
Permission.php:24, AvoRed\Framework\Support\Middleware\Permission->handle()
Authenticate.php:43, AvoRed\Framework\Support\Middleware\AdminAuth->handle()
--- app/vendor/avored/framework/routes/web.php
--- Route::middleware(['web', 'admin.auth:admin', 'permission'])
AvoRedCore.php:36, AvoRed\Framework\Support\Middleware\AvoRedCore->handle()
SubstituteBindings.php:41, Illuminate\Routing\Middleware\SubstituteBindings->handle()
VerifyCsrfToken.php:78, App\Http\Middleware\VerifyCsrfToken->handle()
ShareErrorsFromSession.php:49, Illuminate\View\Middleware\ShareErrorsFromSession->handle()
StartSession.php:56, Illuminate\Session\Middleware\StartSession->handle()
AddQueuedCookiesToResponse.php:37, Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle()
EncryptCookies.php:67, App\Http\Middleware\EncryptCookies->handle()
Pipeline.php:171, Illuminate\Routing\Pipeline->Illuminate\Pipeline\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:147-180}()
Pipeline.php:105, Illuminate\Routing\Pipeline->then()
--- Kernel.$middlewareGroups.webの実行
Router.php:683, Illuminate\Routing\Router->runRouteWithinStack()
Router.php:658, Illuminate\Routing\Router->runRoute()
Router.php:624, Illuminate\Routing\Router->dispatchToRoute()
Router.php:613, Illuminate\Routing\Router->dispatch()
Kernel.php:170, App\Http\Kernel->Illuminate\Foundation\Http\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:167-171}()
Pipeline.php:130, Illuminate\Routing\Pipeline->Illuminate\Pipeline\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:128-136}()
InjectDebugbar.php:67, Barryvdh\Debugbar\Middleware\InjectDebugbar->handle()
TrustProxies.php:57, App\Http\Middleware\TrustProxies->handle()
TransformsRequest.php:21, Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle()
TransformsRequest.php:21, App\Http\Middleware\TrimStrings->handle()
ValidatePostSize.php:27, Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle()
CheckForMaintenanceMode.php:63, App\Http\Middleware\CheckForMaintenanceMode->handle()
--- Kernel.$middlewareの実行 
Pipeline.php:171, Illuminate\Routing\Pipeline->Illuminate\Pipeline\{closure:/var/www/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:147-180}()
Pipeline.php:105, Illuminate\Routing\Pipeline->then()
Kernel.php:145, App\Http\Kernel->sendRequestThroughRouter()
Kernel.php:110, App\Http\Kernel->handle()
index.php:55, {main}()

コントローラーの処理例

<?php

namespace App\Http\Controllers\Product;

use Illuminate\Http\Request;
use AvoRed\Framework\Database\Contracts\ProductModelInterface;
use AvoRed\Review\Database\Contracts\ProductReviewModelInterface;
use App\Http\Controllers\Controller;

class ProductController extends Controller
{
    /**
     * @var \AvoRed\Framework\Database\Repository\ProductRepository
     */
    protected $productRepository;
    /**
     * @var \AvoRed\Review\Database\Repository\ProductReviewRepository
     */
    protected $productReviewRepository;

    /**
     * home controller construct.
     */
    public function __construct(
        ProductModelInterface $productRepository,
        ProductReviewModelInterface $productReviewRepository
    ) {
        $this->productRepository = $productRepository;
        $this->productReviewRepository = $productReviewRepository;
    }

    /**
     * Show the application dashboard.
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function show($slug)
    {
        $product = $this->productRepository->findBySlug($slug);
        $reviews = $this->productReviewRepository->getAllReviewsByProductId($product->id);
        $product->images;

        return view('product.show')
            ->with(compact('product', 'reviews'));
    }
}

特に特筆することはない。コンスタクターで依存関係のクラスをDIしてアクションメソッド内でそれらを使用して、viewオブジェクトをレスポンスしているだけ。