How to deduce existence of photons by applying quantum mechanics to Maxwell's equations Watching this video lecture of Peter Higgs https://youtu.be/QtudlGHoBQ8?t=372, he says (roughly) at one point that Paul Dirac applied quantum mechanics to Maxwell's field equations and deduced the existence of photons (previously predicted by Einstein in the photoelectric effect?).

Question. Mathematically, how does one obtain the existence of photons (or photon-like particles) by applying quantum mechanics to Maxwell's equations of electromagnetism?

Disclaimer. I'm a mathematician by training, with pedestrian knowledge in Physics.
 A: Historically, quantum mechanics was first postulated by Planck as a way to solve the ultraviolet catastrophe that arose when trying to apply thermodynamics to electromagnetism. So, it's not so much that we have quantum mechanics and applied it to E&M, we had E&M and statistical mechanics/thermodynamic and the mismatch between them gave the first hint at QM.
That said, I'll outline a plausible path from Maxwell's equations to being able to deduce in quantum field theory that photons exist as particles.
First, derive the Hamiltonian from the electromagnetic stress-energy tensor,
$$H = \int \mathrm{d}^3x \left[\frac{\epsilon_0}{2}\mathbf{E}^2 + \frac{1}{2\mu_0} \mathbf{B}^2\right].$$
Second, write the Hamiltonian in terms of the vector potential and electric potential using $\mathbf{E} = -\nabla \Phi - \partial_t \mathbf{A}$ and $\mathbf{B} = \nabla \times \mathbf{A}$ to get
$$H = \int \mathrm{d}^3x \left[\frac{\epsilon_0}{2}(\nabla \Phi + \partial_t \mathbf{A})^2 + \frac{1}{2\mu_0} (\nabla \times \mathbf{A})^2\right].$$
Third, split the Hamiltonian's terms into contributions from the electric field's solenoidal and divergencful parts using Helmholtz decomposition
$$H = \int \mathrm{d}^3x \left[\frac{\epsilon_0}{2}(\nabla \Phi + \partial_t \mathbf{A}_D)^2 + \frac{\epsilon_0}{2}(\partial_t \mathbf{A}_S)^2 + \frac{1}{2\mu_0} (\nabla \times \mathbf{A}_S)^2\right].$$
Identify the momentum canonically conjugate to $\mathbf{A}_S$ is $\mathbf{\Pi}_S = \partial_t\mathbf{A}_S$, and $\mathbf{E}_D = -\nabla \Phi - \partial_t \mathbf{A}_D$ to get
$$H = \int \mathrm{d}^3x \left[\frac{\epsilon_0}{2}\mathbf{E}_D^2 + \frac{\epsilon_0}{2}\mathbf{\Pi}_S^2 + \frac{1}{2\mu_0} (\nabla \times \mathbf{A}_S)^2\right].$$
Finally, Fourier transform into mode-space (i.e. Fourier transform the spatial dimensions, not time)
\begin{align}
H &= \int \mathrm{d}^3k \left[\frac{\epsilon_0}{2}\mathbf{E}_D^* \cdot \mathbf{E}_D  + \frac{\epsilon_0}{2}\mathbf{\Pi}_S^* \cdot \mathbf{\Pi}_S + \frac{1}{2\mu_0} |\mathbf{k} \times \mathbf{A}_S|^2\right] \\
&=\int \mathrm{d}^3k \left[\frac{\epsilon_0}{2}\mathbf{E}_D^*\cdot \mathbf{E}_D + \frac{\epsilon_0}{2}\mathbf{\Pi}_S^*\cdot \mathbf{\Pi}_S + \frac{k^2}{2\mu_0} \mathbf{A}_S^*\cdot \mathbf{A}_S\right].
\end{align}
By inspection you can now see that the electromagnetic field consists of two components that are continuum harmonic oscillators (the solenoidal terms) that obey $\omega = k / \sqrt{\mu_0\epsilon_0}$, and one component that is not (the divergenceful term). The harmonic oscillator type terms are what give rise to the states of definite particle number via the ladder operator formalism, and hence, photons.
The divergenceful (non-photon supporting) term deserves some commentary. In the Weyl gauge it's a kinetic term (because it's the square of a time derivative of a coordinate), in the Coulomb gauge it's a potential term (the square of a space derivative of a coordinate), and it's mixed in other gauges. Regardless, parameterizing it in terms of the electric field satisfies gauge invariance, and is not a problem quantum mechanically since it has no canonically conjugate counterpart in the Hamiltonian. That means the states of definite $\mathbf{E}_D$ are also eigenstates of the Hamilton.
Of course, this gets more complicated when you start including sources, $\rho$ and $\mathbf{J}$, but only a little so. For more details, I would recommend Chapter 8 of Weinberg's The Quantum Theory of Fields (Volume 1).
A: Here's a stab at a short and intuitive answer (i.e. math lite). Warning, I ignore basically all factors that aren't equal to 1 so sorry if I get something wrong. $\hbar = \pi = 1/2 = 2 = 4 = 1...$ etc.
Solutions to Maxwell's equations can be decomposed into monochromatic electromagnetic waves*. An electromagnetic wave has an (complex) amplitude $a\propto E$ which oscillates in time.
It can be shown that the energy (or energy flux depending on the exact physical situation) in the electromagnetic wave is proportional to the squared amplitude of the wave:
$$
H = \omega a^*a
$$
Instead of expressing the amplitude as a single complex number we can express it in terms of the real an imaginary parts of that number:
$$
a = \text{Re}(a) + i \text{Im}(a) = x + i p
$$
$$
H/\omega = x^2 + p^2
$$
WERE this a mass on a spring harmonic oscillator we would identify $x$ and $p$ as the canonically conjugate position and momentum variables for the classical harmonic oscillator. These are known to have a Poission bracket like
$$
\{x, p\} = 1
$$
Canonical quantization works by elevating the canonically conjugate variables to quantum operators (can be thought of as operators on a Hilbert space) with commutation relations:
$$
[\hat{x}, \hat{p}] = i
$$
It then follows that
$$
[\hat{a}, \hat{a}^{\dagger}] = 1
$$
from which one can derive that
$$
H = \omega\hat{a}^{\dagger} \hat{a} = \omega\hat{n}
$$
Where the eigenvalues of $\hat{n}$ are non-negative integers. This is what is meant by the energy of the harmonic oscillator being quantized. Note that this implies that the complex amplitude of the harmonic oscillator is quantized as well.
Back to the electromagnetic field. It turns out** that 1) electromagnetism can be cast in a Lagrangian form, thus giving us a context in which we can discuss canonically conjugate variables and 2) The real and imaginary parts of the electromagnetic field amplitude, $a$, given by $x$ and $p$, can in fact be related to a pair of conjugate variables of electromagnetism. These conjugate variables are related to the electric field and the time derivative of the electric field. There are also relationships, through Maxwell's equations, to the magnetic field.
This means that we are justified in making the theory of electromagnetism quantum by letting $a\rightarrow \hat{a}$ with
$$
[\hat{a},\hat{a}^{\dagger}]=1
$$
This leads us to the conclusion that the energy in a single mode of the electromagnetic is quantized in units of $\omega$, and likewise the amplitude of the electromagnetic wave is also quantized.
This is what a photon is. A photon is a quantized excitation in the electomagnetic wave, in the same way we can have a quantized excitation in the quantum harmonic oscillator. Also, at this point I'll point out that it is possible to have excitations in the classical electromagnetic field as well. If you ever find yourself feeling funny about photons try to spend more time thinking about the similarities, rather than the differences, between classical excitations of the electromagnetic field (or any oscillator) and quantum excitations of the same.
As described in the comments, the photon arises from electromagnetism through an application of canonical quantization to the canonically conjugate variables which make up a single-mode monochromatic solution to Maxwell's equations.
*These are often taken to be plane waves, but, depending on the boundary conditions for the EM problem, we can decompose the general solution to Maxwell's equations into many different families of spatial modes. Any such decomposition suffices for the description of a photon. The shape of the photon is given by the spatial pattern of the spatial mode that we are quantizing. That is photons can have different shapes, and a photon in one mode can be decomposed as a superposition of photons in other modes. There, I answered about 100 physics stack exchange questions about the shape of a photon in this footnote!
**My favorite references for this are Quantum and Atom Optics by Daniel Steck and UC Berkeley Physics 221A/B Lecture Notes by Robert Littlejohn.
