I usually just implement a custom route in these cases.
1. Implement the route:
class SomeCustomRoute implements \Zend\Mvc\Router\Http\RouteInterface {
public function __construct(MyDataAccessLayer $db) { ... }
/* implementation details here (look at existing http routes in the
framework */
}
2. define a factory/closure to get your route registered. In your config,
define following key:
'route_manager' => array(
'factories' => array(
'MyFoo' => function ($sl) { return new
SomeCustomRoute($sl->getServiceLocator()->get('MyDataAccessLayer'); },
),
),
3. in your routing config, add your new 'MyFoo' route:
'router' => array(
'routes' => array(
'user-profile-page' => array(
'type' => 'MyFoo',
'options' => array(/* these optons can eventually be passed to
the factory */),
),
),
)
You can look at how it was done in ZfrRest (
https://github.com/zf-fr/ZfrRest ) ;)
Marco Pivetta
http://twitter.com/Ocramius
http://ocramius.github.com/
On 7 July 2013 00:05, meh [via Zend Framework Community] <
[email protected]> wrote:
> Can anyone point to a good 'complete' vanity url tutorial/guide to create
> twitter/facebook style member urls?
>
> I'm trying to get:
> http://domain.tld/membersname
>
> But still have normal urls segments like:
> http://domain.tld/contact
> http://domain.tld/about
> http://domain.tld/news/look-what-happened
> etc
>
> I already have a db or reserved url slugs which I can use to prevent
> members registering (contact,about,news,etc) but I can not work out how to
> poll a db for member names?
>
> I suppose I want to check default urls slugs first then if no match check
> members db or fail to a 404.
>
> Info I have found are mainly ZF1 implementations and the couple of ZF2
> examples are extreme presumtive that you know ZF2 as their is not step
> guides just general discussion.
>
> Much appreciated.
>
>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://zend-framework-community.634137.n4.nabble.com/Twitter-style-vanity-urls-with-Zend-Framework-2-2-tp4660531.html
> To start a new topic under Zend Framework, email
> [email protected]
> To unsubscribe from Zend Framework Community, click
> here<http://zend-framework-community.634137.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=634137&code=b2NyYW1pdXNAZ21haWwuY29tfDYzNDEzN3wxNzE0OTI1MTk4>
> .
> NAML<http://zend-framework-community.634137.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
View this message in context:
http://zend-framework-community.634137.n4.nabble.com/Twitter-style-vanity-urls-with-Zend-Framework-2-2-tp4660531p4660533.html
Sent from the Zend Framework mailing list archive at Nabble.com.