When I build a pillbox, I like to do it at ground-level, build external walls then carve them, entry is up from below (at least two levels of stair from access tunnel), fully roofed (or another level above ostensibly for R&R, but that is fully roofed) and a ditch dug immediately up against the footprint (two tilewidthsor more, removing all pill-edge ramps - hence the deeper level of access) where that level-difference matters not due to horizontal closeness.
(If I've ruined the ground below, for some reason, e.g. chasming ditch across which I've set a bridge-causeway (probably already lever-switched into a falling-trap scenario), I've been known to construct drop-nacelle "pillboxes" supported and accessed from above, located a tile or so away from the causeway with nothing beneath them but air, for whatever arbitrary Zs applies. Construction is more complex, and other belly-gunner constructs could be hovering above the route as well. It's mostly for my inner enjoyment than any greater practicalities such systems might enjoy.)
Optional-but-often I make at least one of the pillbox walls a raising bridge-barrier, instead, to pass over the ditch (or sometimes to meet a bridge coming from the other direction, especially over deeper and wider sections of ditch) lever-controlled from my lever-room, along with every other such sally-port and wagon-entry. Every now and then this is useful for emergency ingress or egress (with further protections/complications in the length of access tunnel before it gets to the fort-proper, in more satellite-like pillbox designs).