こんな / そんな / あんな / どんな + ふうに こういう / そういう / ああいう / どういう + ふうに [verb (plain)] + ふうに [na-adj] + な + ふうに
ふうに means "this way", "in a way that": it describes how something is done or how it comes across. Most of the time it follows a こそあど word – こんなふうに, そんなふうに, どんなふうに – and it can also follow a plain verb, like any noun.
こういうふうに and どういうふうに mean the same and are just as common in speech. ふうに is conversational; in writing, このように takes its place.
After a plain verb or a な-adjective, ふうに describes how someone seems, and often hints that the reality is different.
Both can mean "the way". Only ように gives a purpose, "so that".
ふうに does not follow a noun with の. "Like a teacher" is せんせい先生のように or せんせい先生みたいに, not ×先生のふうに.