Wayfinder documentation


Why Wayfinder?

Wayfinder is primarily a routing system that just happens to be perfect for rapidly prototyping websites, web apps and APIs. Your code is neatly organised and with basic MVC principles in mind, you can keep your data models, views and logic all separated.

Getting started

Grab the code from GitHub. Point your host to the www folder and all of your logic lives in the app folder. You'll know it was successful because you'll see this documentation at yourhost.com/documentation.

The best place to start exploring the code base is the app/conf/routes.php file or the app/controllers folder. When you first install Wayfinder you should see the documentation which is a simple example of how custom routes work.

To start adding your own end points to your website, app or API, read more about routes in Wayfinder.

Helper methods in Wayfinder

Wayfinder comes with some methods available instantly in your models and controllers.

load($type (models, views, controller, libraries), $file, $data = [])

Use the load() method to load other parts of your application. You can use it to load models and/or views into your controller for example.

$this->load('views', 'docs');

Just pass the type of file you're including and the file path + name (without the extension), to automatically include it.

Show pseudo-code

Passing data to your views

When loading a view file, you can pass your data as a third parameter. This should be in an array format which is re-interpreted to expose some variables for use within your templates.

$data = [
    'title' => 'My Page Title',
    'items' => [

$this->load('views', 'myView', $data);

This example passes a title and a list of items to the view. The view then has access to the following two variables:

echo $title; // My Page Title
var_dump($items); // ['first', 'second', 'third']

redirect($location, $code = 301)

If you need to redirect to a new location, use the redirect() method to take the user there and pass the apprioraite error. Any code after calling redirect() will not be executed. Passing a HTTP status code is optional, Wayfinder assumes you are performing a permanent redirect.

$this->redirect('/', 301);
Show pseudo-code
header('Location: '.$location, true, $code)

You can see the redirect() method in action by going to /readdocs which will bring you straight back here.


By adding a file extension to your URL, you can automatically determine the right format for the page. As an example, this page can be requested with the .txt extension.

By using the $this->getMimeType() method, you can create logic to help you make the right choice.

if($this->getMimeType() !== 'txt') {
    // your regular display logic
} else {
    // return a plain text file

If no file extension is specified, then every page is treated as HTML but you can explicitly choose from the following list of supported file extensions:

  • .html (default)
  • .txt
  • .xml
  • .rss
  • .atom
  • .json

Need more help?