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.
        
        
        
        
        
        
        
        
        
     
        
       

  • 相关阅读:
    自制对焦测试卡
    RHEL AS4上配置snmpd遇到问题及解决办法笔记
    一个OID资料集中网站
    mrtg配置小问题
    sybase 优化总结[zt]
    [ZT] solarwinds 2002工程师版本(带注册机)
    推荐四个网盘资源搜索工具
    Hadoop 集群搭建
    分布式文件系统 HDFS 简介
    HDFS Shell 命令实操
  • 原文地址:https://www.cnblogs.com/shuman/p/5478175.html
Copyright © 2011-2022 走看看