How can we show that $\int_{0}^{2\pi}{x\over \phi-\cos^2(x)}\mathrm dx=2\pi^2?$ We have the integral

$$\int_{0}^{2\pi}{x\over \phi-\cos^2(x)}\mathrm dx=2\pi^2\tag1$$
  $\phi$; Golden ratio

What method do we employ to prove $(1)$?
An attempt:
If we use $u=\phi-\cos^2 x$ then $\int_{\phi-1}^{\phi-1}(...)du=0$
Another way, $(1)$ becomes
$${1\over 2\sqrt{\phi}}\int_{0}^{2\pi}\left({x\over \sqrt{\phi}-\cos x}-{x\over \sqrt{\phi}+\cos x} \right)\mathrm dx\tag2$$
We got a hint by using 
$z=\tan{x\over 2}$, $dx={2dz\over 1+z^2}$, $\cos x={1-z^2\over 1+z^2}$ and $\sin x={2z\over 1+z^2}$
Let try on
$$\int_{0}^{2\pi}{x\over \sqrt{\phi}+\cos x}\mathrm dx=4\int_{0}^{0}{\tan^{-1} z\over (1+z^2)\sqrt{\phi}+1-z^2}\cdot (1-z^2)\mathrm dz=0?\tag3$$
Doesn't seem to work.
How else can we prove $(1)$?
 A: Since it may be in any case instructive, let me try to give the full residue-method solution.
Choosing the branch cut of the logarithm along the positive real axis, let us apply the residue theorem to the corresponding keyhole contour $\Gamma$, which, as sketched in the figure, goes around the point $z=z_1=\sqrt{2\phi-3}=-z_2$ from above and  below. We obtain:
$$
\oint_\Gamma \frac{4z\log z}{z^4-2(2\phi-1)z^2+1}dz = i2\pi\frac{\log z_2}{z_2^2-(2\phi-1)} = -i\pi\log z_1 +\pi^2, 
$$
where we have used that $z_{2}$ is the only root of the denominator enclosed in the integration contour and we have substituted $\log z_2 = \log(z_1e^{i\pi})=\log z_1+i\pi$. 
The integration contour $\Gamma$ can be split into its six pieces: the unit circle $C_1$, two segments above and below the real axis, two half-circles $\gamma^\pm_\varepsilon$ around $z_1$ and a small circle around the origin. As the radius $\varepsilon$ of the small circle and of $\gamma_\varepsilon^\pm$ tends to zero, these pieces yield (care is needed because we are comparing quantities across a branch cut):
$$\begin{aligned}
\oint_\Gamma \frac{4z\log z}{z^4-2(2\phi-1)z^2+1}dz =&\ 
\int_0^{2\pi}\frac{t}{\phi-\cos^2t}dt\\
&- \mathrm{PV} \int_0^1 \frac{4x(\log x +i2\pi)}{x^4-2(2\phi-1)x^2+1}dx\\
&-i\pi \frac{\log z_1 + i2\pi}{z_1^2-(2\phi-1)}\\
&+0\\
&+\mathrm{PV} \int_0^1 \frac{4x\log x }{x^4-2(2\phi-1)x^2+1}dx\\
&-i\pi \frac{\log z_1}{z_1^2-(2\phi-1)}\\
=&\int_0^{2\pi}\frac{t}{\phi-\cos^2t}dt -\pi^2\\
&-i8\pi\, \mathrm{PV}\int_0^1\frac{x}{x^4-2(2\phi-1)x^2+1}dx+i\pi\log z_1,
\end{aligned}
$$
where $\mathrm{PV}$ denotes the Cauchy principal value.
By comparison of the real parts,
$$
\int_{0}^{2\pi}\frac{t}{\phi-\cos^2t}dt=2\pi^2.
$$
Furthermore, by comparison of the imaginary parts, we get the bonus identity
$$
\mathrm{PV} \int_{0}^{1}\frac{ x}{x^4-2(2\phi-1)x^2+1}dx=\frac{1}{4}\log z_1=\frac{1}{8}\log(\sqrt{5}-2).
$$
Alio modo: let us consider instead the complex function
$$
f(z)=\frac{z}{\phi-\cos^2z}=\frac{-4ze^{i2z}}{(e^{i2z}-e^{i2\zeta_1})(e^{i2z}-e^{i2\zeta_3})},
$$
where $\zeta_1=-i\log\sqrt{2\phi-3}=\zeta_2-\pi$ and $\zeta_3=-i\log\sqrt{2\phi+1}=\zeta_4-\pi$. This function has simple poles at $\zeta_1$, $\zeta_2$ in the upper half plane and $\zeta_3$, $\zeta_4$ in the lower half plane, up to integer multiples of $2\pi$.

Denoting by $\Pi$ the rectangular contour sketched in the figure
, with half-circular indents of radius $\varepsilon$ around $\zeta_1$ and $\zeta_1+2\pi$, we have
$$
\oint_\Pi f(z) dz=i2\pi \,\text{Res}f(\zeta_2)=i2\pi\lim_{z\to\zeta_2}(z-\zeta_2)f(z)=\pi^2-i\pi\log\sqrt{2\phi-3}.
$$
Furthermore, in the limits $M\to\infty$ and $\varepsilon\to0$, from the various pieces of the integration contour
we get:
$$\begin{aligned}
\oint_\Pi f(z) dz =&\ \int_0^{2\pi}\frac{t}{\phi-\cos^2t}dt\\
       &\ +\mathrm{PV} \int_0^\infty \frac{2\pi+iy}{\phi-\cosh^2y}idy\\
       &\ -0\\
       &\ -\mathrm{PV} \int_0^\infty \frac{iy}{\phi-\cosh^2y}idy\\
       &\ -i\pi \,\text{Res}f(\zeta_1)\\
       &\ -i\pi \,\text{Res}f(\zeta_1+2\pi)\\
      =&\ \int_0^{2\pi}\frac{t}{\phi-\cos^2t}dt-\pi^2\\
       &\ i2\pi\, \mathrm{PV} \int_0^\infty \frac{dy}{\phi-\cosh^2y}+i\pi\log\sqrt{2\phi-3}.  
\end{aligned}$$
Again, by comparison:
$$
\begin{aligned}
\int_0^{2\pi}\frac{t}{\phi-\cos^2t}dt&=2\pi^2\\
\mathrm{PV} \int_0^\infty \frac{dy}{\phi-\cosh^2y}&=\frac{1}{2}\log(2\phi-3).
\end{aligned}
$$
A: Instead of starting from your integral, I will start from the integral in the solution by @Mickep, i.e,
$$\tag{1}I=4\pi\int_0^{\pi/2}\frac{1}{\phi-\cos^2x}\,dx=\pi\underbrace{\int_0^{2\pi}\frac{1}{\phi-\cos^2x}\,dx}_{J} $$
on which it will be simpler to explain how to compute an integral using residue calculus than on the original integral. I will not enter into details. For this I refer you to the numerous lecture notes on residue calculus, for example here.
The main idea is to transform this integral into a circuit integral along a closed parametrized arc, which is here, in a natural way, the unit circle $\gamma$, traversed in the direct orientation. 
Let $z=e^{ix}$, with $dz=ie^{ix}dx$. 
Thus, $J$ becomes, using Euler formula $\cos(x)=\frac12(e^{ix}+e^{-ix})$:
$$J=\int_{\gamma}\dfrac{-i dz/z}{\Phi-\dfrac{(z+1/z)^2}{4}}$$
Expanding and reducing, we get:
$$\tag{2}J=-i \underbrace{\int_{\gamma}\dfrac{4z dz}{-z^4+2(2\Phi-1)z^2-1}}_{K}$$
The integrand has four poles (roots of the denominator), all of them real:
$$\begin{cases}z_1=\sqrt{2 \Phi -3} \ \ \ \text{and } \ \ \ z_2=-z_1=-\sqrt{2 \Phi -3}\\
z_3=\sqrt{1+2 \Phi} \ \ \ \text{and } \ \ \ z_4=-z_3=-\sqrt{1+2 \Phi}\end{cases}$$
Only $z_1$ and $z_2$ are inside contour $\gamma.$
The residue theorem says that a complex integral $\int_{\gamma}...$ whatever the sufficiently regular closed contour $\gamma$, is equal to the sum of residues at the poles situated inside the contour multiplied by $2i\pi$.
Now, what is the residue of a function of the form $\dfrac{f(z)}{g(z)}$ at a pole $z_0$? It is the number given by the following formula:
$$\dfrac{f(z_0)}{g'(z_0)}.$$
Although this is not the most general definition, this expression covers a large number of cases (see remark below). 
Thus, the residue theorem gives:
$$K=2i\pi\left(\dfrac{4z_1 }{-4z_1^3+4(2\Phi-1)z_1}+\dfrac{4z_2}{-4z_2^3+4(2\Phi-1)z_2}\right)$$
$$K=2i\pi\left(\dfrac{1}{-z_1^2+(2\Phi-1)}+\dfrac{1}{-z_2^2+(2\Phi-1)}\right)$$
As $z_1^2=z_2^2=2\Phi-3$, the denominators have a common value, which is $-2$.
Thus $K=-2i\pi$. Plugging this value into (2) and then (1) gives the awaited result.
Remark: The definition of residues I have given is only valid for simple poles; if $z_0$ is for example a double root of the denominator, it is understandable that we are in trouble because  $g'(z_0)=0$. There exist specific formulas for these cases.
A: Here is a route, I leave it to you to fill in the details:
$$
\begin{aligned}
\int_0^{2\pi}\frac{x}{\phi-\cos^2x}\,dx
&=\int_0^\pi\frac{x}{\phi-\cos^2x}\,dx+\int_0^{\pi}\frac{x+\pi}{\phi-\cos^2(x+\pi)}\,dx\\
&=2\int_0^\pi\frac{x}{\phi+\sin^2x-1}\,dx+\int_0^\pi\frac{\pi}{\phi-\cos^2x}\,dx\\
&=2\frac\pi2\int_0^\pi\frac{1}{\phi+\sin^2x-1}\,dx+\int_0^\pi\frac{\pi}{\phi-\cos^2x}\,dx\\
&=2\pi\int_0^\pi\frac{1}{\phi-\cos^2x}\,dx\\
&=4\pi\int_0^{\pi/2}\frac{1}{\phi-\cos^2x}\,dx\\
&=4\pi\int_0^{\pi/2}\frac{1}{\cos^2x}\frac{1}{\phi\tan^2x+\phi-1}\,dx\\
&=4\pi\biggl[\frac{1}{\sqrt{\phi(\phi-1)}}\arctan\Bigl(\sqrt{\frac{\phi}{\phi-1}}\tan x\Bigr)\biggr]_0^{\pi/2}\\
&=4\pi\frac{1}{\sqrt{\phi(\phi-1)}}\frac\pi2\\
&=2\pi^2.
\end{aligned}
$$
A: A purely real approach.
Consider the integral
$$C(a,b)=\int_0^{\pi}\frac{\mathrm dx}{a+b\cos(x)^2}$$
It has already been shown by other users that your integral is given by $2\pi C(\phi,-1)$. 
We commence with the substitution $t=\tan\frac{x}2$:
$$C(a,b)=2\int_0^\infty \frac1{a+b\left[\frac{1-t^2}{1+t^2}\right]^2}\frac{\mathrm dt}{1+t^2}$$
$$C(a,b)=2\int_0^\infty\frac{1+t^2}{a(t^2+1)^2+b(t^2-1)^2}\mathrm dt$$
$$C(a,b)=2\int_0^\infty\frac{1+t^2}{(a+b)t^4+2(a-b)t^2+a+b}\mathrm dt$$
$$C(a,b)=\frac2{a+b}\int_0^\infty\frac{1+t^2}{t^4+2gt^2+1}\mathrm dt$$
Where $g=\frac{a-b}{a+b}$. We may split up the integral:
$$C(a,b)=\frac2{a+b}\int_0^\infty\frac{\mathrm dt}{t^4+2gt^2+1}+\frac2{a+b}\int_0^\infty\frac{t^2\mathrm dt}{t^4+2gt^2+1}$$
Then we pay attention to $$N_{n}(s)=\int_0^\infty \frac{x^{2n}}{x^4+2sx^2+1}\mathrm dx$$
With the substitution $x=1/u$, we have 
$$N_n(s)=-\int_\infty^0 \frac{\frac1{u^{2n}}}{\frac1{u^4}+\frac{2s}{u^2}+1}\frac{\mathrm du}{u^2}$$
$$N_n(s)=\int_0^\infty \frac{u^{2-2n}\mathrm du}{u^4+2su^2+1}$$
$$N_n(s)=N_{1-n}(s)$$
So we have
$$C(a,b)=\frac4{a+b}\int_0^\infty\frac{\mathrm dt}{t^4+2gt^2+1}$$
For this remaining integral, we recall that 
$$\begin{align}
\frac1{x^4+(2-c^2)x^2+1}&=\frac1{(x^2+cx+1)(x^2-cx+1)}\\
&=\frac1{4c}\frac{2x+c}{x^2+cx+1}-\frac1{4c}\frac{2x-c}{x^2-cx+1}+\frac14\frac1{x^2+cx+1}+\frac14\frac1{x^2-cx+1}
\end{align}$$
So we have that 
$$K(c)=\int_0^\infty \frac{\mathrm dx}{x^4+(2-c^2)x^2+1}$$
becomes
$$K(c)=\frac1{4c}\int_0^\infty\frac{2x+c}{x^2+cx+1}\mathrm dx-\frac1{4c}\int_0^\infty\frac{2x-c}{x^2-cx+1}\mathrm dx\\
+\frac14\int_0^\infty \frac{\mathrm dx}{x^2+cx+1}+\frac14\int_0^\infty \frac{\mathrm dx}{x^2-cx+1}$$
The first two integrals are easy, and end up vanishing, so we end up with 
$$K(c)=\frac14I(1,c,1)+\frac14I(1,-c,1)$$
Where 
$$I(a,b,c)=\int_0^\infty \frac{\mathrm dx}{ax^2+bx+c}=\frac2{\sqrt{4ac-b^2}}\arctan\frac{2ax+b}{\sqrt{4ac-b^2}}\bigg]_0^\infty\\
=\frac\pi{\sqrt{4ac-b^2}}-\frac2{\sqrt{4ac-b^2}}\arctan\frac{b}{\sqrt{4ac-b^2}}$$
Hence
$$K(c)=\frac\pi{2\sqrt{4-c^2}}$$
So we see that
$$C(a,b)=\frac4{a+b}K\left(2\sqrt{\frac{b}{a+b}}\right)=\frac\pi{\sqrt{a^2+ab}}$$
And since, by definition, $\phi^2-\phi=1$, we have that 
$$C(\phi,-1)=\pi$$
Which gives, as desired,
$$\int_0^{2\pi}\frac{x\mathrm dx}{\phi-\cos(x)^2}=2\pi^2$$
A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$

With $\ds{\phi \equiv {1 + \root{5} \over 2} \approx 1.6180}$:

\begin{align}
&\bbox[10px,#ffd]{\int_{0}^{2\pi}{x \over \phi - \cos^{2}\pars{x}}\,\dd x} =
\int_{-\pi}^{\pi}{x + \pi \over \phi - \cos^{2}\pars{x}}\,\dd x =
2\pi\int_{0}^{\pi}{\dd x \over \phi - \cos^{2}\pars{x}}
\\[5mm] = &\
2\pi\int_{-\pi/2}^{\pi/2}{\dd x \over \phi - \sin^{2}\pars{x}} =
4\pi\int_{0}^{\pi/2}{\dd x \over \phi - \sin^{2}\pars{x}}
\\[5mm] = &\
4\pi\int_{0}^{\pi/2}{\sec^{2}\pars{x} \over
\phi\sec^{2}\pars{x} - \tan^{2}\pars{x}}\,\dd x =
4\pi\int_{0}^{\pi/2}{\sec^{2}\pars{x} \over
\pars{\phi - 1}\tan^{2}\pars{x} + \phi}\,\dd x
\\[5mm] = &\
4\pi\,{1 \over \phi}\,{1 \over \root{1 - 1/\phi}}
\int_{0}^{\pi/2}{\root{1 - 1/\phi}\sec^{2}\pars{x} \over
\bracks{\root{1 - 1/\phi}\tan\pars{x}}^{2} + 1}\,\dd x
\\[5mm] = &\
4\pi\,{1 \over \root{\phi^{2} - \phi}}\
\underbrace{\int_{0}^{\infty}{\dd x \over x^{2} + 1}}
_{\ds{\pi \over 2}}\
=\
{2\pi^{2} \over  \root{\phi^{2} - \phi}} = \bbx{2\pi^{2}} 
\end{align}

because $\ds{\phi^{2} - \phi = \color{red}{1}}$.

A: Using the substitution $x=2\pi - t$ and adding resulting integral to the given one we get $$2I=2\pi\int_{0}^{2 \pi} \frac{dx} {\phi-\cos^2x}$$ or $$I=2\pi\int_{0}^{\pi}\frac{dx}{\phi-\cos ^2x}=4\pi\int_{0}^{\pi/2}\frac{dx}{\phi-\cos^2x}$$ Next using $\cos^2x=(1+\cos 2x) /2$ and substitution $t=2x$ we get $$I=4\pi\int_{0}^{\pi}\frac{dt}{2\phi-1-\cos t} $$ Using the formula $$\int_{0}^{\pi}\frac{dx}{a+b\cos x} =\frac{\pi} {\sqrt{a^2-b^2}},a>|b|$$ we can see that $$I=\frac{4\pi^2}{\sqrt{(2\phi-1)^2-1}}=2\pi^2$$
