Views 本文未发布 发布文章

未匹配的标注

Definition & Principles

Read from the Porto SAP Documentation (#Views).

Rules

  • Views SHOULD be created inside the Containers. And they will be automatically available for use in the Web Controllers.
  • All Views are namespaced as the lower case of the Container name.

Folder Structure

 - app
    - Containers
        - {container-name}
            - UI
                - WEB
                    - Views
                        - welcome.php
                        - profile.php
                        - ...

Code Sample

Welcome page View

<!DOCTYPE html>
<html>
<head>
    <title>Welcome</title>
</head>
<body>
<div class="container">
    <div class="content">
        <div class="title">Welcome</div>
    </div>
</div>
</body>
</html>

Example: Usage From Controller

<?php

namespace App\Containers\Welcome\UI\WEB\Controllers;

use App\Ship\Parents\Controllers\WebController;

class Controller extends WebController
{
    public function sayWelcome()
    {
        return view('just-welcome');
    }
}

Namespaces

By default all the Container Views are namespaced to the Container name.

Example:

If a Container named Store has View say-hello, you can access the view like this view('store::just-welcome'). If you try to access it without the namespace view('just-welcome'), it will not find your View.

本文章首发在 LearnKu.com 网站上。

上一篇 下一篇
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
讨论数量: 0
发起讨论 只看当前版本


暂无话题~