Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config option to set TreeRouteStack::baseUri #3

Open
weierophinney opened this issue Dec 31, 2019 · 4 comments
Open

Config option to set TreeRouteStack::baseUri #3

weierophinney opened this issue Dec 31, 2019 · 4 comments

Comments

@weierophinney
Copy link
Member

In every project I see people working around the Url ViewHelper not working in console context.

If there was a config option like below we could have one standardized way of solving this.

<?php // config/autoload/server-url.local.php

return [
    'server_url' => 'https://example.com'
]

Example of my latest workaround: https://stackoverflow.com/a/52248041/1899162

Secondarily we could then also use this option to make the ServerUrl ViewHelper work in console context.

@weierophinney do you want this PR for this repository or for Zend\View?


Originally posted by @Erikvv at zendframework/zend-router#51

@lon9man
Copy link

lon9man commented Jun 13, 2024

6 years passed since original post..
guys, any roadmap or best practice?

who can clearly describe how to use url-helper (ServerUrl and others) inside console-application?
thanks!

@froschdesign
Copy link
Member

@lon9man

who can clearly describe how to use url-helper (ServerUrl and others) inside console-application?

Create and register a factory for the helper which uses the configuration. Here is an example.

@lon9man
Copy link

lon9man commented Jun 13, 2024

@froschdesign thanks for the reply!
i checked sources.

questions:

  1. i don't see in UrlFactory something related to server_url-option in config. will it assemble routes in console successfully?
  2. i don't see laminas-mvc-view-library in the docs/google. what is it? it was made to resolve this specific issue with ServerUrl?

thanks!

@froschdesign
Copy link
Member

@lon9man

  1. i don't see in UrlFactory something related to server_url-option in config. will it assemble routes in console successfully?

The Url helper does not create fully qualified domain name (absolute URL) by default and is not intended for this purpose at all.
For CLI usage you can combine the ServerUrl helper and the Url helper or replace the Url helper with a custom one.

2. i don't see laminas-mvc-view-library in the docs/google. what is it? it was made to resolve this specific issue with ServerUrl?

This new / unreleased package extracts the MVC components from laminas-view with the goal of using laminas-view and its Url helpers as a standalone and providing (better) CLI support.


If you have any further questions, please use the forum or the chat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants