Zend_Application-AvailableResources-Frontcontroller.xml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect2 id="zend.application.available-resources.frontcontroller">
  4. <title>Zend_Application_Resource_Frontcontroller</title>
  5. <para>
  6. Probably the most common resource you will load with
  7. <classname>Zend_Application</classname> will be the Front Controller resource,
  8. which provides the ability to configure
  9. <classname>Zend_Controller_Front</classname>. This resource provides the ability
  10. to set arbitrary front controller parameters, specify plugins to
  11. initialize, and much more.
  12. </para>
  13. <para>
  14. Once initialized, the resource assigns the <varname>$frontController</varname>
  15. property of the bootstrap to the <classname>Zend_Controller_Front</classname>
  16. instance.
  17. </para>
  18. <para>
  19. Available configuration keys include the following, and are case
  20. insensitive:
  21. </para>
  22. <itemizedlist>
  23. <listitem>
  24. <para>
  25. <emphasis><property>controllerDirectory</property></emphasis>: either a string value
  26. specifying a single controller directory, or an array of
  27. module to controller directory pairs.
  28. </para>
  29. </listitem>
  30. <listitem>
  31. <para>
  32. <emphasis><property>moduleControllerDirectoryName</property></emphasis>: a string
  33. value indicating the subdirectory under a module that contains controllers.
  34. </para>
  35. </listitem>
  36. <listitem>
  37. <para>
  38. <emphasis><property>moduleDirectory</property></emphasis>: directory under which
  39. modules may be found.
  40. </para>
  41. </listitem>
  42. <listitem>
  43. <para>
  44. <emphasis><property>defaultControllerName</property></emphasis>: base name of the
  45. default controller (normally "index").
  46. </para>
  47. </listitem>
  48. <listitem>
  49. <para>
  50. <emphasis><property>defaultAction</property></emphasis>: base name of the default
  51. action (normally "index").
  52. </para>
  53. </listitem>
  54. <listitem>
  55. <para>
  56. <emphasis><property>defaultModule</property></emphasis>: base name of the default
  57. module (normally "default").
  58. </para>
  59. </listitem>
  60. <listitem>
  61. <para>
  62. <emphasis><property>baseUrl</property></emphasis>: explicit base
  63. <acronym>URL</acronym> to the application (normally auto-detected).
  64. </para>
  65. </listitem>
  66. <listitem>
  67. <para>
  68. <emphasis><property>plugins</property></emphasis>: array of front controller plugin
  69. class names. The resource will instantiate each class (with no constructor
  70. arguments) and then register the instance with the front controller.
  71. </para>
  72. </listitem>
  73. <listitem>
  74. <para>
  75. <emphasis><property>params</property></emphasis>: array of key to value pairs to
  76. register with the front controller.
  77. </para>
  78. </listitem>
  79. </itemizedlist>
  80. <para>
  81. If an unrecognized key is provided, it is registered as a front
  82. controller parameter by passing it to <methodname>setParam()</methodname>.
  83. </para>
  84. <example id="zend.application.available-resources.frontcontroller.configExample">
  85. <title>Sample Front Controller resource configuration</title>
  86. <para>
  87. Below is a sample <acronym>INI</acronym> snippet showing how to configure the front
  88. controller resource.
  89. </para>
  90. <programlisting language="ini"><![CDATA[
  91. [production]
  92. resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
  93. resources.frontController.moduleControllerDirectoryName = "actions"
  94. resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
  95. resources.frontController.defaultControllerName = "site"
  96. resources.frontController.defaultAction = "home"
  97. resources.frontController.defaultModule = "static"
  98. resources.frontController.baseUrl = "/subdir"
  99. resources.frontController.plugins.foo = "My_Plugin_Foo"
  100. resources.frontController.plugins.bar = "My_Plugin_Bar"
  101. resources.frontController.env = APPLICATION_ENV
  102. ]]></programlisting>
  103. </example>
  104. <example id="zend.application.available-resources.frontcontroller.propertyExample">
  105. <title>Retrieving the Front Controller in your bootstrap</title>
  106. <para>
  107. Once your Front Controller resource has been initialized, you can
  108. fetch the Front Controller instance via the
  109. <varname>$frontController</varname> property of your bootstrap.
  110. </para>
  111. <programlisting language="php"><![CDATA[
  112. $bootstrap->bootstrap('frontController');
  113. $front = $bootstrap->frontController;
  114. ]]></programlisting>
  115. </example>
  116. </sect2>