[Yii2] Widget 建構與目錄架構 – Widget Pattern

Intro

Yii2 Application Structure: Widgets


Directory Structure

通用(共用)Widget架構

your_app (e.g. frontend)/
    - widgets/
        - assets/
            - js/
                - hedaer.js
            - css/
                - header.css
        - views/
            - hedaer.php
        - HeaderWidget.php
        - HeaderWidgetAsset.php

通用架構上,assets即可以考慮另外移至web外層以省搬移成本。

獨立Widget架構

your_app (e.g. frontend)/
    - widgets/
        - header/
            - assets/
            - js/
                - index.js
            - css/
                - index.css
            - views/
                - index.php
            - Widget.php
            - Asset.php

Leave a Reply

Your email address will not be published. Required fields are marked *