Skip to content

Instantly share code, notes, and snippets.

@immutef
Created May 5, 2010 13:54
Show Gist options
  • Save immutef/390792 to your computer and use it in GitHub Desktop.
Save immutef/390792 to your computer and use it in GitHub Desktop.
Symfony2 DI container for Zend Framework
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://www.symfony-project.org/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.symfony-project.org/schema/dic/services http://www.symfony-project.org/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="views_dir">%root_dir%/views/default</parameter>
<parameter key="view.suffix">php</parameter>
</parameters>
<services>
<service id="cache" class="Zend_Cache" constructor="factory">
<argument type="string">Core</argument>
<argument type="string">File</argument>
<argument type="collection">
<argument key="automatic_serialization">true</argument>
</argument>
<argument type="collection">
<argument type="string" key="cache_dir">%cache_dir%</argument>
</argument>
</service>
<service id="config" class="Zend_Config_Xml">
<argument type="string">%config_dir%/settings.xml</argument>
<argument>null</argument>
<argument>true</argument>
</service>
<service id="db.config" class="Zend_Config_Xml">
<argument type="string">%config_dir%/database.xml</argument>
</service>
<service id="db" class="Zend_Db" constructor="factory">
<argument type="service" id="db.config" />
</service>
<service id="locale" class="Zend_Locale">
<argument type="constant">Zend_Locale::BROWSER</argument>
</service>
<service id="request" class="Zend_Controller_Request_Http" />
<service id="response" class="Zend_Controller_Response_Http" />
<service id="router.config" class="Zend_Config_Xml">
<argument type="string">%config_dir%/routing.xml</argument>
</service>
<service id="router" class="Zend_Controller_Router_Rewrite">
<argument type="collection">
<argument type="string" key="useDefaultRoutes">false</argument>
</argument>
<call method="addConfig">
<argument type="service" id="router.config" />
</call>
</service>
<service id="dispatcher" class="Zend_Controller_Dispatcher_Standard" />
<service id="controller" class="Zend_Controller_Front" constructor="getInstance">
<call method="setDispatcher">
<argument type="service" id="dispatcher" />
</call>
<call method="setRequest">
<argument type="service" id="request" />
</call>
<call method="setResponse">
<argument type="service" id="response" />
</call>
<call method="setRouter">
<argument type="service" id="router" />
</call>
<call method="setControllerDirectory">
<argument type="string">%root_dir%/controllers</argument>
</call>
<call method="throwExceptions">
<argument>%debug%</argument>
</call>
<call method="returnResponse">
<argument>true</argument>
</call>
</service>
<service id="layout" class="Zend_Layout">
<argument type="collection">
<argument type="string" key="layoutPath">%views_dir%</argument>
<argument type="string" key="viewSuffix">%view.suffix%</argument>
</argument>
<argument>true</argument>
<call method="setView">
<argument type="service" id="view" />
</call>
</service>
<service id="view" class="Zend_View">
<argument type="collection">
<argument type="string" key="basePath">%views_dir%</argument>
<argument type="string" key="encoding">UTF-8</argument>
</argument>
</service>
<service id="view.renderer" class="Zend_Controller_Action_HelperBroker" constructor="getStaticHelper">
<argument type="string">viewRenderer</argument>
<call method="setView">
<argument type="service" id="view" />
</call>
<call method="setViewSuffix">
<argument type="string">%view.suffix%</argument>
</call>
</service>
</services>
</container>
@immutef
Copy link
Author

immutef commented May 5, 2010

It's not that usable for everyone, but it serves me right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment