How page creation works in Perch Runway

In Perch each page of your site is represented by an actual file on disk. Perch Runway is different, using a front controller pattern similar to other CMS solutions. In this post I explain the difference, what it means in terms of development and whether it makes a difference to your content editors.

Perch and “physical files”

The reason that Perch is such a great solution for retrofitting, adding a CMS to an existing set of pages, is that each page in Perch admin is an actual page of the website. You can FTP into your server and see the actual file about.php that is your about page. This makes things really simple and quick for small sites.

If you add a new page from the Perch control panel, Perch creates an actual file on disk. This can either be a complete file with all of the markup copied from a Master Page, or a stub file that references a Master Page. If referencing a page we essentially include the master page in the new file meaning that you can make changes to the master page and they will update any pages created from it.

This process works really well for small sites. It becomes strained however on larger and more complex sites. It makes it harder to move content around, and means that if you want to do more work on a site you have to carefully download all of the created page files to your local or staging version of the site.

Perch Runway and the Front Controller

A front controller pattern means that every request to your website is routed to one physical file, in Runway this is start.php. That file contains logic that works out which page should be displayed. The “page” is then generated from template files and database content and served to the browser. As far as the browser or a search engine is concerned there is no difference at all between a file on disk and a file generated in this way. A browser can’t tell what happened on the server to deliver the page, it requests http://example.com/about and receives a page at that location.

The benefit of this for larger sites is that to pull down all of your site content and pages, you just need to grab a database export. No need to ensure that you have all of the created files from the web server. You can also move “pages” around more easily by updating the routing information, and you don’t end up with permissions issues when creating files on badly configured servers.

Master pages in Perch Runway

Master Pages in Perch Runway therefore take on a slightly different role. Instead of copying their content or including the Master Page in a PHP page, we reference them as the source of layout information when creating a page in Perch Runway. Other than that however, Master Pages can be developed in the same way as in Perch.

Creating Pages in Perch Runway

When you create a page it will have a URL which is used to display the page, just as normal. You can optionally also set up multiple URLs, or patterns of URLs that route through to that same page. Creating more complex routes is really handy if you are migrating a site from another system and want to maintain the URLs. For many purposes, for example if you create an about page at /about the default will be all you need.

What do clients or content editors see?

The beauty of this system is that, as far as your client and content editors are concerned there is no difference between pages on disk and pages in the database. If you create a page in the top level of your site at /about the editor will log into admin and see that About page in the list. We don’t believe that content editors should be exposed to how the system works under the hood, and we work very hard to make sure that you can make their editing process as simple as possible – even if your site becomes complex.