Zend_Application-AvailableResources-Frontcontroller.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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><para>
  24. <emphasis><property>controllerDirectory</property></emphasis>: either a string value
  25. specifying a single controller directory, or an array of
  26. module to controller directory pairs.
  27. </para></listitem>
  28. <listitem><para>
  29. <emphasis><property>moduleControllerDirectoryName</property></emphasis>: a string value
  30. indicating the subdirectory under a module that contains
  31. controllers.
  32. </para></listitem>
  33. <listitem><para>
  34. <emphasis><property>moduleDirectory</property></emphasis>: directory under which
  35. modules may be found.
  36. </para></listitem>
  37. <listitem><para>
  38. <emphasis><property>defaultControllerName</property></emphasis>: base name of the
  39. default controller (normally "index").
  40. </para></listitem>
  41. <listitem><para>
  42. <emphasis><property>defaultAction</property></emphasis>: base name of the default
  43. action (normally "index").
  44. </para></listitem>
  45. <listitem><para>
  46. <emphasis><property>defaultModule</property></emphasis>: base name of the default
  47. module (normally "default").
  48. </para></listitem>
  49. <listitem><para>
  50. <emphasis><property>baseUrl</property></emphasis>: explicit base <acronym>URL</acronym>
  51. to the application (normally auto-detected).
  52. </para></listitem>
  53. <listitem><para>
  54. <emphasis><property>plugins</property></emphasis>: array of front controller plugin
  55. class names. The resource will instantiate each class (with no constructor
  56. arguments) and then register the instance with the front controller.
  57. </para></listitem>
  58. <listitem><para>
  59. <emphasis><property>params</property></emphasis>: array of key to value pairs to
  60. register with the front controller.
  61. </para></listitem>
  62. </itemizedlist>
  63. <para>
  64. If an unrecognized key is provided, it is registered as a front
  65. controller parameter by passing it to <methodname>setParam()</methodname>.
  66. </para>
  67. <example id="zend.application.available-resources.frontcontroller.configExample">
  68. <title>Sample Front Controller resource configuration</title>
  69. <para>
  70. Below is a sample <acronym>INI</acronym> snippet showing how to configure the front
  71. controller resource.
  72. </para>
  73. <programlisting language="ini"><![CDATA[
  74. [production]
  75. resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
  76. resources.frontController.moduleControllerDirectoryName = "actions"
  77. resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
  78. resources.frontController.defaultControllerName = "site"
  79. resources.frontController.defaultAction = "home"
  80. resources.frontController.defaultModule = "static"
  81. resources.frontController.baseUrl = "/subdir"
  82. resources.frontController.plugins.foo = "My_Plugin_Foo"
  83. resources.frontController.plugins.bar = "My_Plugin_Bar"
  84. resources.frontController.env = APPLICATION_ENV
  85. ]]></programlisting>
  86. </example>
  87. <example id="zend.application.available-resources.frontcontroller.propertyExample">
  88. <title>Retrieving the Front Controller in your bootstrap</title>
  89. <para>
  90. Once your Front Controller resource has been initialized, you can
  91. fetch the Front Controller instance via the
  92. <varname>$frontController</varname> property of your bootstrap.
  93. </para>
  94. <programlisting language="php"><![CDATA[
  95. $bootstrap->bootstrap('frontController');
  96. $front = $bootstrap->frontController;
  97. ]]></programlisting>
  98. </example>
  99. </sect2>