docs

Various Yii 3.0 related documentation

View the Project on GitHub yiisoft/docs

Overview

Yii applications code is typically grouped into modules by context. In each module there could be grouping by type.

For example, if the application is an online store, context could be:

For a “Customer” context, residing under App\Customer namespace, structure would be:

App/
  Customer/                          <-- module namespace
    Entity/
      Customer.php                   <-- entity shared by "Profile" and "Checkout"
    Profile/
      Widget/
        Gravatar.php
      ProfileRepository.php          <-- repository is usually specific to context
      ProfileController.php          <-- "Customer\Profile" entry point
    ProductList/                     <-- module namespace 
      Entity/                        <-- entities specific to "Customer\ProductList"
        Category.php
        Product.php
      ProductsListController.php     <-- "Customer\ProductList" entry point
    Checkout/                        <-- module namespace
      CheckoutController.php

A context may include sub-contexts. If a class is shared by multiple contexts, it’s moved to the ancestor of both contexts.

A context may have an entry point known as “action” or “controller”. Its job is to take a request instance, pass it to domain layer in a suitable format, and create a response based on what’s returned by domain layer.

Besides, Yii applications also have the following: