to_action() doesn't exist in L4. The action function is extended to handle parameters instead. So this line should read:

    $url = URL::action('user@profile', [$username]);
or maybe
    $url = URL::action('UserController@getProfile', [$username]);
to avoid introducing a new action syntax.