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的实例

  • 相关阅读:
    网速测速结果,单位换算
    js实现多个列表分别倒计时功能
    微信小程序使用wxs在页面中调用js函数,颜色值格式转换 rgb和十六进制的转换
    css样式列表宽度自适应布局
    投资轮次说明
    Ajax与JSON共同使用的小实例
    js结构
    关于vue的小实例
    label与input之间的对应
    购物demo
  • 原文地址:https://www.cnblogs.com/zack86/p/5688094.html
Copyright © 2011-2022 走看看