How is Fubini's theorem used in the following proof?

You missed the hypothesis that $\phi(0)=0$ and that $f\geqslant0$ almost everywhere, then, for every nonnegative $s$, $$\phi(s)=\int_0^s\phi'(t)\mathrm dt=\int_0^\infty\phi'(t)\mathbf 1_{s\gt t}\mathrm dt.$$ Now, $f(x)\geqslant0$ for $\mu$-almost every $x$ hence $$\phi\circ f(x)=\int_0^\infty\phi'(t)\mathbf 1_{f(x)\gt t}\mathrm dt.$$ Integrating both sides with respect to $\mu$ and interverting, thanks to Tonelli theorem applied to the product measure $\mu\otimes\mathrm{Leb}$ on $X\times[0,\infty)$, the integral on $X$ with respect to $\mu$ and the integral on $[0,\infty)$ with respect to $\mathrm{Leb}$, one gets $$\int_X\phi\circ f(x)\mathrm d\mu(x)=\int_X\left(\int_0^\infty\phi'(t)\mathbf 1_{f(x)\gt t}\mathrm dt\right)\mathrm d\mu(x)=\int_0^\infty\phi'(t)\left(\int_X\mathbf 1_{f(x)\gt t}\mathrm d\mu(x)\right)\mathrm dt,$$ and the proof is complete since, for every $t$, the inner parenthesis on the RHS is $\mu\{f\gt t\}$.