For how to do this mathematically ina simple way, see here, where they use \theta instead of \phi. This might also help. So, assuming that your $\phi$ coordinate is the azimuthal angle in the x-y plane, then the transformation to find the directional vector is
$$ \vec{e}_{\phi} = \frac{\partial \vec{r}}{\partial \phi} = -rsin(\phi)\hat{e}_{x} + rcos(\phi)\hat{e}_{y}$$
The unit vector is defined as, since the directional vectors are not necessarily of unit length,
$$ \hat{e}_{\phi} = \frac{\vec{e}_{\phi}}{|\vec{e}_{\phi}|}$$
So we have that,
$$ \hat{e}_{\phi} = \frac{\vec{e}_{\phi}}{r}$$
Next, to remove the explicit $\phi$ and $r$ dependence, we apply the coordinate transformation equations given here:
$$ r = \sqrt{x^{2} + y^{2}}$$
$$ \phi = arctan\Big(\frac{y}{x}\Big)$$
So, we have,
$$ \hat{e}_{\phi} = \frac{\vec{e}_{\phi}}{\sqrt{(rcos(\phi))^{2} + (rsin(\phi))^{2}}} = \frac{\vec{e}_{\phi}}{r}$$
$$ \hat{e}_{\phi} = \frac{-rsin(\phi)\hat{e}_{x} + rcos(\phi)\hat{e}_{y}}{r} = \frac{-y\vec{e}_{x} + x\vec{e}_{y}}{\sqrt{x^{2} + y^{2}}}$$
where we used the fact that $x = rcos(\phi)$ and $y = rsin(\phi)$.