PHPackages                             webfactory/legacy-integration-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. webfactory/legacy-integration-bundle

ActiveLibrary[Framework](/categories/framework)

webfactory/legacy-integration-bundle
====================================

A battle-proven approach to facilitate the incremental migration of legacy applications to the Symfony2 stack.

3.1.0(1w ago)1611.6k↓89.3%2MITPHPPHP &gt;= 8.1

Since Jul 3Pushed 1w ago11 watchersCompare

[ Source](https://github.com/webfactory/WebfactoryLegacyIntegrationBundle)[ Packagist](https://packagist.org/packages/webfactory/legacy-integration-bundle)[ RSS](/packages/webfactory-legacy-integration-bundle/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (42)Versions (58)Used By (0)

WebfactoryLegacyIntegrationBundle
=================================

[](#webfactorylegacyintegrationbundle)

This bundle provides an approach to integrate existing legacy applications with Symfony2.

In brief, the approach is to run a particular event listener on the kernel.controller event. This event listener will decide whether and how to run the legacy application. The response generated by the legacy application will then be captured.

Later, after the Symfony2 Controller has been executed and a Twig template is being rendered, fragments of the "legacy response" can be retrieved and be used as part of the output.

That way, you can start with your legacy application and Symfony2 in coexistence next to each other. You can then incrementally start to shift functionality over to the Symfony2 stack while maintaining a coherent user experience.

Because Symfony2 is driving this process and Twig templates have the control authority of which parts of the legacy response are being used, this approach will naturally "grow" away from the legacy application towards the Symfony2 stack.

*Take care:* This bundle currently uses webfactory/dom, a small set of utilities on top of PHP's DOM extension, to process the legacy application's repsonse and provide XPath-based access to it. It will only work if your old application returns well-formed XHTML or Polyglot HTML5.

To learn more about this concept, its benefits and caveats, use your time-machine and visit the [Symfony2 User Group Colone meeting on 2013-12-18](http://de.slideshare.net/webfactory/marry-me-public).

Installation
------------

[](#installation)

Just like any other Symfony2 bundle, left as an exercise to the reader.

Configuration
-------------

[](#configuration)

```
webfactory_legacy_integration:
    # Whether your legacy application returns text/html as XHTML 1.0 or Polyglot HTML5.
    parsingMode: xhtml10|html5
    # Bootstrap file for the legacy application (see next section)
    legacyApplicationBootstrapFile: www/index-legacy.php

```

The legacy "bootstrap" file
---------------------------

[](#the-legacy-bootstrap-file)

You must provide a single file that can be `include()`ed in order to run your legacy application. Typically you will already have this - it should be your legacy application's front controller.

If you are running PHP &lt; 5.4, this file should *return* the HTTP status code sent by the legacy application. Starting with PHP 5.4, `http_response_code()`will be used to detect it.

Also, as this bundle will try to capture the response including headers using output buffering, you must not flush the response body or headers to the client.

Using it
--------

[](#using-it)

Once you're set up, use the @Dispatch annotation on your controller to run the legacy application before your controller - like so:

```
