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 网站上。

上一篇 下一篇
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 0
发起讨论 查看所有版本


暂无话题~