2017 © Pedro Peláez
 

library magl-legacy-application

Provides a ZF2 module that is able to run legacy applications with the power of ZF2.

image

maglnet/magl-legacy-application

Provides a ZF2 module that is able to run legacy applications with the power of ZF2.

  • Friday, January 13, 2017
  • by maglnet
  • Repository
  • 3 Watchers
  • 4 Stars
  • 7,607 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 14 Versions
  • 7 % Grown

The README.md

MaglLegacyApplication - Legacy Applications in Laminas

Latest Stable Version Scrutinizer Code Quality License Build Status Code Coverage, (*1)

Run your legacy applications within Laminas., (*2)

Introduction

Since rewriting your legacy application from scratch to a Laminas application could be nearly impossible due to time, effort, and resources, I was searching for a way to migrate a legacy application to a Laminas application., (*3)

A [great article by Chris Abernethy][1] described a way on how to run your legacy application within ZF1, so I migrated this HowTo to a small Laminas module, to be able to run a legacy application within Laminas., (*4)

While running your legacy application within a Laminas application it is possible to slowly migrate an existing application to Laminas by leaving your old application (nearly - see "Adjust your legacy Application") untouched and build new modules with the power of Laminas.
By adding a simple wrapper (see "Using Laminas within your legacy application") you could also use the new modules within your legacy application., (*5)

Installation

Install through composer, (*6)

{
    "require" : {
        "maglnet/magl-legacy-application" : "*"
    }
}

Enable the module within your Laminas application.config.php, (*7)

    'modules' => array(
        'Application',
        'MaglLegacyApplication',
    ),

Copy the provided file data/magl-laminas-legacy-wrapper.php to your public/ folder.
Copy the provided file data/.htaccess to your publix folder.
Copy your legacy Application to your public/ folder., (*8)

Your legacy application should now run within Laminas. :), (*9)

Configuration

For any SEO optimized route within your legacy application, add a route to the zend router that routes to legacy controller and remove the mod_rewrite rules from your .htaccess, (*10)

return array(
    'router' => array(
        'routes' => array(
            // example for transferring mod rewrite rules to laminas routes
            'legacy-seo-calendar' => array(
                'type' => 'Laminas\Mvc\Router\Http\Regex',
                'options' => array(
                    'regex'    => '/calendar/(?<foo>.+)',
                    'defaults' => array(
                        'controller' => 'MaglLegacyApplication\Controller\Legacy',
                        'action'     => 'index',
                        'script'     => 'index-already-seo-optimized.php',
                    ),
                    'spec' => '/',
                ),
            ),
        ),
    ),
);

Adjust your legacy Application

There are several cases in which your legacy application won't run without additional adjustments, here are some of them:, (*11)

Relative Paths

Using relative paths for require, require_once or includes will possibly fail now, since Laminas will do a chdir() to the Laminas' application root. So you will need to adjust your paths to match the new root., (*12)

Example:, (*13)

include '../lib/somelib.php';

should be changed to:, (*14)

include __DIR__ . '/../lib/somelib.php';

Using Globals / Server SCRIPT_FILENAME or SCRIPT_NAME

Because of mod_rewrite rules, SCRIPT_FILENAME and SCRIPT_NAME won't be your real script anymore. If you use these variables, you need to adjust these places within your legacy application:, (*15)

Example:, (*16)

$script_filename = $_SERVER['SCRIPT_FILENAME'];
$script_name     = $_SERVER['SCRIPT_NAME'];

should be changed to:, (*17)

use MaglLegacyApplication\Application\MaglLegacy;
$legacy          = MaglLegacy::getInstance();
$script_filename = $legacy->getLegacyScriptFilename();
$script_name     = $legacy->getLegacyScriptName();

Using Laminas within your legacy application

use MaglLegacyApplication\Application\MaglLegacy;
$application = MaglLegacy::getInstance()->getApplication();
$yourService = $application->getServiceManager()->get('YourService');

Injecting responses from within your legacy application

from wherever you are within your legacy application, it is possible to bypass your legacy applications controller code and send a response to the Laminas Controller wrapper. This response will then be handled like within a normal Laminas controller., (*18)

use MaglLegacyApplication\Application\MaglLegacy;
$application = MaglLegacy::getInstance()->getApplication();
$application->getEventManager()->getSharedManager()->attach('*', MaglLegacy::EVENT_SHORT_CIRCUIT_RESPONSE, function(Event $e){
    $response = new \Laminas\Http\Response();
    $response->setStatusCode(404);
    $response->setContent('not found');
    $e->stopPropagation(true);
    return $response;
});

Contributing

If you have questions or problems regarding this module just open an issue or, even better, solve it and open a pull request. :+1:, (*19)

The Versions

13/01 2017

dev-master

9999999-dev https://github.com/maglnet/MaglLegacyApplication

Provides a ZF2 module that is able to run legacy applications with the power of ZF2.

  Sources   Download

BSD-3

The Requires

 

The Development Requires

zf2 zend framework legacy legacy application

13/01 2017

1.7.0

1.7.0.0 https://github.com/maglnet/MaglLegacyApplication

Provides a ZF2 module that is able to run legacy applications with the power of ZF2.

  Sources   Download

BSD-3

The Requires

 

The Development Requires

zf2 zend framework legacy legacy application

02/08 2016

1.6.1

1.6.1.0 https://github.com/maglnet/MaglLegacyApplication

Provides a ZF2 module that is able to run legacy applications with the power of ZF2.

  Sources   Download

BSD-3

The Requires

 

The Development Requires

zf2 zend framework legacy legacy application

29/04 2016

1.6.0

1.6.0.0 https://github.com/maglnet/MaglLegacyApplication

Provides a ZF2 module that is able to run legacy applications with the power of ZF2.

  Sources   Download

BSD-3

The Requires

 

The Development Requires

zf2 zend framework legacy legacy application

04/04 2016

1.5.1

1.5.1.0 https://github.com/maglnet/MaglLegacyApplication

Provides a ZF2 module that is able to run legacy applications with the power of ZF2.

  Sources   Download

BSD-3

The Requires

 

The Development Requires

zf2 zend framework legacy legacy application

30/03 2016

1.5.0

1.5.0.0 https://github.com/maglnet/MaglLegacyApplication

Provides a ZF2 module that is able to run legacy applications with the power of ZF2.

  Sources   Download

BSD-3

The Requires

 

The Development Requires

zf2 zend framework legacy legacy application

29/01 2016

1.4.1

1.4.1.0 https://github.com/maglnet/MaglLegacyApplication

Provides a ZF2 module that is able to run legacy applications with the power of ZF2.

  Sources   Download

BSD-3

The Requires

 

The Development Requires

zf2 zend framework legacy legacy application

07/09 2015

1.4.0

1.4.0.0 https://github.com/maglnet/MaglLegacyApplication

Provides a ZF2 module that is able to run legacy applications with the power of ZF2.

  Sources   Download

BSD-3

The Requires

 

The Development Requires

zf2 zend framework legacy legacy application

23/06 2015

1.3.1

1.3.1.0 https://github.com/maglnet/MaglLegacyApplication

Provides a ZF2 module that is able to run legacy applications with the power of ZF2.

  Sources   Download

BSD-3

The Requires

 

The Development Requires

zf2 zend framework legacy legacy application

22/06 2015

1.3.0

1.3.0.0 https://github.com/maglnet/MaglLegacyApplication

Provides a ZF2 module that is able to run legacy applications with the power of ZF2.

  Sources   Download

BSD-3

The Requires

 

The Development Requires

zf2 zend framework legacy legacy application

08/05 2015

1.2.0

1.2.0.0 https://github.com/maglnet/MaglLegacyApplication

Provides a ZF2 module that is able to run legacy applications with the power of ZF2.

  Sources   Download

BSD-3

The Requires

 

The Development Requires

zf2 zend framework legacy legacy application

31/01 2015

1.1.0

1.1.0.0 https://github.com/maglnet/MaglLegacyApplication

Provides a ZF2 module that is able to run legacy applications with the power of ZF2.

  Sources   Download

BSD-3

The Requires

 

The Development Requires

zf2 zend framework legacy legacy application

16/06 2014

1.0.0

1.0.0.0 https://github.com/maglnet/MaglLegacyApplication

Provides a ZF2 module that is able to run legacy applications with the power of ZF2.

  Sources   Download

BSD-3

The Requires

 

zf2 zend framework legacy legacy application

29/05 2014

0.1.0

0.1.0.0 https://github.com/maglnet/MaglLegacyApplication

Provides a ZF2 module that is able to run legacy applications with the power of ZF2.

  Sources   Download

BSD-3

The Requires

 

zf2 zend framework legacy legacy application