The first key is to use a high f-stop. Start by practicing in your backyard when the sun is coming through the trees. Set your camera to a higher f-stop for more detail. For example, if I use a low f-stop like f/2.8 or f/1.8, I’m going to get a buttery, blurry background (my favorite for portraits!). But if I use a high f-stop (f/8, f/12 or f/16), I’m going to have detail in the foreground, background, even in the light rays (my favorite for travel photography)! Lots of point-and-shoot cameras now let you change your f-stop/aperture. If you have a DSLR camera, put it in Aperture Priority mode and choose your high f-stop.
Camera: Sony a6300 Lens: E 16mm f/2.8 ISO 100, Aperture: f/16, Shutter Speed: 1/25th of a sec