SlimPHP 2.x Custom Classes for Routes

If you want custom classes for your slim project you can do so by adding a route in the index.php file like this:

Now if your namespace is called foo and the Class bar with a function baz you then your file foo/bar.php will look like:

To Get to the $app variable in the custom class (for getting post variables for instance) you can add this to your Class:

If you will be having a lot of classes, you can add this to a parent class, and have Bar extend that class Like so: