zoukankan      html  css  js  c++  java
  • [Phalcon-framework] Phalcon framework

    Registering services in the Container

    - We can easily replace a component with one created by ourselves or a third party.
    - We have full control of the object initialization, allowing us to set these objects, as needed before delivering them to components.
    - We can get global instances of components in a structured and unified way.

    Services can be registered using serverial types of definitions:

    <?php

        use PhalconHttpRequest;
        // Create the Dependency Injector Container
        $di = new PhalconDi();
        // By its class name
        $di->set("request", "PhalconHttpRequest");
        
        // Using an anonymous function, the instance will be lazy loaded
        $di->set("request", function () {
            return new Request();
        });
        
        // Regsitering an instance directly
        $di->set("request", new Request());
        
        // Using an array definition
        $di->set(
            "request",
            array(
                "className" => 'PhalconHttpRequest'
            )
        );
     
    <?php
     
     // The array syntax is also allowed to register service:
        
        use PhalconHttpRequest;
        // Create the Dependency Injector Container
        $di = new PhalconDi();
        
        // By its class name
        $di['request'] = 'PhalconHttpRequest';
        // Using an anonymous function, the instance will be lazy loaded
        $di['request'] = function () {
            return new Request();
        };
        
        // Registering an instance directly
        $di["request"] = new Request();
        
        // Using an array definition
        $di['request'] = array(
            "className" => 'PhalconHttpRequest'
        );
        
        
    Models
        
        A model represents the information (data) of the application and the rules to manipulate that data. Models are primaryly used for managing the rules of interaction with a corresponding database table. In most cases, each table in your database will correspond to one model in your application. The bulk of your application's business logic will be concentrated in the models.
        
    Views
        
        view represent the user interface of your applicaiton. Views are often HTML files with embeded PHP coe that perform tasks related solely to the presentation of the data. Views handle the job of providing data to the web browser or other tool that is used to make requests from your application.
        
     Controllers
     
        The controllers provide the "flow" between models and views. Controllers are responsible for processing the incoming requests from the web browser, interrogating the models for data, and passing that data on to the views for presentation.
        
        
        
        
        
        
        
        
        
     
        
       

  • 相关阅读:
    PetShop4.0学习笔记[01]:订单处理[01]——多线程程序结构
    PetShop4.0学习笔记——使用命名空间
    PetShop 4.0学习笔记:消息队列MSMQ
    petshop4 MSDTC 不可用解决
    经典工具软件备份
    ASP.NET知识点(三):购物车与收藏蓝的实现[Profile]
    PetShop 4.0知识点:加密和解密Web.config文件的配置节
    PetShop 4.0知识点:base 关键字用于从派生类中访问基类的成员
    从Word,Excel中提取Flash
    线性结构
  • 原文地址:https://www.cnblogs.com/shuman/p/5478175.html
Copyright © 2011-2022 走看看