Chapter 14. Decouple URL Paths from File Paths

Even though we have a document root that separates our public and non-public resources, the users of our legacy application still browse directly to our page scripts. This means that our URLs are coupled directly to file system paths on the web server.

Our next step is to decouple the paths so that we can route URLs independently to any target we want. This means putting in place a Front Controller to handle all incoming requests for our legacy application.

Coupled Paths

As we noted in the previous chapter, our web server acts as a combined front controller, router, and dispatcher for our legacy application. The routes to the page scripts are still mapped directly onto the file system, using our docroot/ ...

Get Modernizing Legacy Applications in PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.