Here's my solution - I have a bunch of shelves like this around the garage, 24" deep. I use lag screws into the studs, as well as the heavy duty shelf supports from Home Despot. The 2x4 frame is held together with 3" deck screws, with 1 5/8" screws to hold down the plywood.