This will render a link like this:, (*7)
<a href="/hello-world">Click me</a>
Parametrized routes
Soflomo\Prototype
supports route parameters with the segment type route in Zend Framework 2. This means you could have a route like /foo/bar/:id
. By default, the module only uses literal routes to match the exact url. This is faster, but less flexible. You can specify to have the segment type by an additional type
key:, (*8)
'homepage' => array(
'type' => 'segment',
'route' => '/foo/bar/:id',
'template' => 'mockup/foo-bar'
),
These routes types are extremely useful when dealing with existing applications. If you have an application where you deal with parametrized routes, you want to have a parametrized route for your mockup page as well. This way, you could always navigate back to your real application when a user vists the mocked page., (*9)
Why?
You might ask why we built this module and did not use a micro framework like Silex. Or, why we do not start in Zend Framework 2 directly., (*10)
To answer the first, micro frameworks are hard to combine with existing Zend Framework 2 applications. We (at Soflomo) need a way to create prototypes also for existing applications. If we prototype a new design for a new module, the existing site with existing designs and existing modules should be kept intact., (*11)
However, "normal" Zend Framework 2 configuration is quite some work if you only want to connect routes with view scripts. Frontend developers can easily copy/paste above code for a new module and they are up and running. It simply costs too much time and effort to use the existing nested routes, create controllers, actions, make them loadable via configuration, fetch the view template from the route match options and return a correctly configured view model. For fast protyping, you now just add four lines for a page name, route and view script and it Just Works (tm)., (*12)
Development
Soflomo\Prototype
is intended to create prototypes really fast, but this module is by no means intended for production usage. It is (at this moment) not tested, not stable and there are no guarantees it is bug-free. Use at your own risk!, (*13)
If you want to join development or found any bug, feel free to fork this project and make your adjustments. Create a pull request to ask for the changes to be merged back in Soflomo\Prototype
. If you have any questions about this module, feel free to contact us at jurian@juriansluiman.nl., (*14)