We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Micro routing with URL

I am building an API using micro application, and I am trying to pass an URL through get, it seems router couldn't accpet http url straight away.

https://i.xy.com/agent/https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png

$app->map('/agent/{url:(.*)}', [
        $image,
        "agentAction"
    ])->via(['GET']);

In action, the URL I got is https:/www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png, which is missing a slash after https, does anyone experience a case like this before?



8.4k

i couldn't figure the proper solution but i got one and its ugly but it works

$app->get(
    "/agent/{url:(.*)}",
    function ($url) {
        exit(var_dump(substr($_SERVER['REQUEST_URI'], strlen($this->config->application->baseUri . 'agent/'))));
    }
);