The classical theory of electromagnetism is entirely revised in this book by proposing a variant of Maxwell equations that allows solitonic solutions (photons). The Lagrangian is the standard one, but it is minimized on a constrained space that enforces the wave packets to follow the rules of geometrical optics. Exact solutions are explicitly shown; this opens a completely new perspective for the study of light wave phenomena. In the framework of general relativity, the equations are written in covariant form. A coupling with the metric is obtained through the Einstein equation, whose solutions are computed exactly in a lot of original situations. Finally, the explicit construction of elementary particles, consisting of rotating photons, is indicated. The results agree qualitatively and quantitatively with what it is actually observed. This opens the path to an understanding of the structure of matter and its properties, also aimed to provide a causal explanation to quantum phenomena.