Article

ZF1 Front Controller and Request Dispatch

Understand ZF1 front controller dispatch, routers, and plugins so you can debug legacy routes and plan strangler cutovers.

ZF1’s front controller is the traffic cop: it resolves module/controller/action, runs plugins, and dispatches into action controllers. When a modernization plan says “only replace billing,” you need to know which routes still enter this pipeline.

Dispatch mental model

  1. Request hits public/index.php
  2. Zend_Application bootstraps resources
  3. Front controller router matches
  4. Plugins (preDispatch/postDispatch) run
  5. Action controller method executes and view renders
// LEGACY — custom route in bootstrap
$router = $front->getRouter();
$router->addRoute('invoice', new Zend_Controller_Router_Route(
    'invoice/:id',
    ['controller' => 'invoice', 'action' => 'view']
));
// MODERN strangler — bypass ZF1 for selected paths at the web server
// nginx example idea: location /api/v2/ { try_files → new front controller }
// ZF1 remains default for /app/

Debugging tips

  • Log module/controller/action on preDispatch during staging investigations.
  • Watch for plugins that silently redirect unauthenticated users.
  • Confirm CLI scripts do not accidentally bootstrap the full front controller.

See project structure and migration planning. Error triage: PHP Error Matcher.

Related tools

Related reading