Osx mamp, ports and toolkit url validation

i am using MAMP Pro for OSX. since packaging more and more of my code in plugins (even if not public released) I hit a wall more than once recently since kirby toolkits url validation fails for localhost with ports.
i am also using codekit but its in-build bonjour server has a port number in URI, too.

i can not avoid url validation in general since some kirby, panel or basic toolkit functions use them internally.

v::url( 'http://localhost:8888') == false

any ideas how to solve this. different MAMP Pro settings?

@bnomei I’m not sure I can be much help since I don’t know the context but I’ll try. :slight_smile:

  1. I’m curious, if you’re using MAMP Pro , why not use custom host names? (For example: mysite.local) Personally, I use custom host names for each site I work on within MAMP Pro.
  2. Note: I’m using MAMP Pro with the standard ports (ex: 80, 443, 3306, …).
  3. In CodeKit (I’m on v3.1) I use that custom host name in the “External Server Options”:

Regarding v::url(), would this work for you?

$url = 'http://' . $_SERVER['SERVER_NAME'];

if (v::url($url)) {
    echo "true";  /* I get this... */
    echo $url;    /* http://mysite.local */
} else {
    echo "false";
    echo $url;
}

Seems to work for me. Hope that’s helpful.

(Update: It works with CodeKit’s server url too. In my case: http://hyr.local:5757.)

1 Like

Thanks @hyr for the tips I managed to get it solved.

I am using custom names for my hosts. The solution was to use custom name with a dot inside the string – like you did. its not the port that makes v::url stumble its the missing dot in the domain-part.
when switching to ports (80, 433, …) you can ommit the port, but i don’t care about that.

v::url('http://localhost:8888') == false
v::url('http://local.host:8888') == true
v::url('http://local.host') == true // when port in MAMP is set to 80/443