zoukankan      html  css  js  c++  java
  • Symfony-services.yml这个文件是干啥的

    先来看一个简单的services.yml

    // src/Nlc/InformationBundle/Resources/config/services.yml
    services:
       nlc_information:
           class: NlcInformationBundleServicecService
           arguments: ["初始化参数1", "初始化参数2"]

    如果你在控制器中任意一个方法里打印 $this->container->getServiceIds() 会发现 nlc_information 就在里面,

    也就是说nlc_information是一个service的ID是唯一标识符

    class: 后面跟的就是这个service

    arguments: 后面跟的是实例化这个类的时需要给的到的参数 fcuntion _construct(参数1,参数2)

    ============

    查看已经注册的service的方法是在命令行 (symfony3.1)

    php bin/console debug:container 

    查看指定service的信息为

    php bin/console debug:container zc_service
    E:wwwrootSymfony2symfony-demo>php bin/console debug:container zc_service
    
    Information for Service "zc_service"
    ====================================
    
     ------------------ --------------------
      Option             Value
     ------------------ --------------------
      Service ID         zc_service
      Class              AppBundleUtilsc
      Tags               -
      Public             yes
      Synthetic          no
      Lazy               no
      Shared             yes
      Abstract           no
      Autowired          no
      Autowiring Types   -
     ------------------ --------------------

    具体的Option有以上这么多,我也没有全整明白

    只要是注册到container里的service可以通过 $this->get('zc_service')  获得这个service的实例

  • 相关阅读:
    HDinsight 系列-使用证书登陆中国区Azure
    PowerBI 应用时间智能(生成日期表)
    Hadoop 常用命令之 HDFS命令
    Hadoop分布式集群安装
    DAX:New and returning customers
    Hadoop 安装过程中出现的问题
    ftp 报错 200 Type set to A
    LC.exe 已退出,代码为-1 问题解决
    C# 文件操作
    EfRepository
  • 原文地址:https://www.cnblogs.com/zack86/p/5688094.html
Copyright © 2011-2022 走看看