When I used to fit kitchens I would mostly do what the first poster after the OP suggested when fitting to plasterboard stud walls, i.e. fit a plywood template behind the wall units, securely fixed to the studs, and then fix the wall units through the plyboard.
When fixing to brick / block walls, I always used to fit a batten under as per TJ’s suggestion in addition to the more secure fixing you could get into the solid wall.
Since there is a debate going on that introduced door-hanging into the pot, it’s worth considering the direction of the ‘braces’ on ledged & braced doors / gates. IMO both TJ and GG make correct points but GG is probably being disingenuous in not acknowledging TJ’s assertions regarding the need for a strong enough fixing at the top in addition to the supporting batten. Possibly. 😉