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

Can't get full url instead of root/article/33 #620

Open
amirandev opened this issue Jun 14, 2022 · 2 comments
Open

Can't get full url instead of root/article/33 #620

amirandev opened this issue Jun 14, 2022 · 2 comments

Comments

@amirandev
Copy link

I'm trying to make it show full url (for example: https://site.com/article/33) instead of root/article/33 but the Router::getUrl() returns an object instead of string and you know...

$out = url('search',null, ['q' => 'mitsubishi']);
dump($out);

How can I do that way simple?
https://site.com/article/33

@riku22
Copy link

riku22 commented Jun 21, 2022

Hi.

$out = url('search',null, ['q' => 'mitsubishi'])->getAbsoluteUrl();
dump($out);

How about this?
The point this time is to use getAbsoluteUrl().

@DeveloperMarius
Copy link
Contributor

Hey,
can you explain your goal a little bit more?
I can recieve the current url using:

\Pecee\SimpleRouter\SimpleRouter::get('/article/33', function(){
    var_dump(\Pecee\SimpleRouter\SimpleRouter::request()->getUrl()->getAbsoluteUrl());
});

You can also name the routes and recieve the url using the following:

\Pecee\SimpleRouter\SimpleRouter::get('/article/{article}', function(){
    var_dump(\Pecee\SimpleRouter\SimpleRouter::getUrl('article-url', array(
        'article' => 33
    ))->getAbsoluteUrl());
})->name('article-url');

~ Marius

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