Traditional SLR cameras do phase detection autofocus by directing light onto AF sensors in the camera’s mirror box. Some newer sensor technologies do away with the need for separate sensors by building the phase detection technology directly into the image sensor.
If you’re curious about the technical details of how these things work, Toshiba just released this (relatively) easy-to-understand 3-minute video that explains how phase detection autofocus works, both with separate AF sensors and with phase-detection sensor pixels.

Started out doing photography at the age of 6 using an uncle's old 1940 kodak brownie box camera. At 15 years of age, I decided to buy my very own 1975 Praktica SLR camera. I now shoot with a Nikon D850. I do unpaid TFP and commercial paid work.