Zend_Application-AvailableResources-Frontcontroller.xml 4.3 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 <code>frontController</code>
  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. <code>controllerDirectory</code>: either a string value
  25. specifying a single controller directory, or an array of
  26. module/controller directory pairs.
  27. </para></listitem>
  28. <listitem><para>
  29. <code>moduleControllerDirectoryName</code>: a string value
  30. indicating the subdirectory under a module that contains
  31. controllers.
  32. </para></listitem>
  33. <listitem><para>
  34. <code>moduleDirectory</code>: directory under which modules may be
  35. found.
  36. </para></listitem>
  37. <listitem><para>
  38. <code>defaultControllerName</code>: base name of the default
  39. controller (normally "index").
  40. </para></listitem>
  41. <listitem><para>
  42. <code>defaultAction</code>: base name of the default action
  43. (normally "index").
  44. </para></listitem>
  45. <listitem><para>
  46. <code>defaultModule</code>: base name of the default module
  47. (normally "default").
  48. </para></listitem>
  49. <listitem><para>
  50. <code>baseUrl</code>: explicit base URL to the application (normally
  51. auto-detected).
  52. </para></listitem>
  53. <listitem><para>
  54. <code>plugins</code>: array of front controller plugin class names.
  55. 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. <code>params</code>: array of key/value pairs to register with the
  60. 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 <code>setParam()</code>.
  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 INI snippet showing how to configure the front
  71. controller resource.
  72. </para>
  73. <programlisting role="ini"><![CDATA[
  74. [production]
  75. resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
  76. resources.frontController.moduleControllerDirectoryName = "actions"
  77. resources.frontController.moduleController = 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. <code>frontController</code> property of your bootstrap.
  93. </para>
  94. <programlisting role="php"><![CDATA[
  95. $bootstrap->bootstrap('frontController');
  96. $front = $bootstrap->frontController;
  97. ]]></programlisting>
  98. </example>
  99. </sect2>