When there’s no space for a photoelectric sensor, there is only one solution: user fiber optics!
If there are no particular demands for toughness an ambient temperature or chemical resistance, then plastic fiber optics are the right choice.
Photoelectric Sensors for Special Applications (BFB/BOS fiber optic base units, BFO fiber optic) PDF
"*" indicates required fields