Flanking
When making a melee attack, you gain a +2 bonus to attack rolls if your opponent is threatened (see page 255) by another creature on its opposite border or opposite corner. Only a creature that threatens the opponent can grant this bonus, and your bonus from flanking can never be higher than +2. Creatures with a reach of 0 feet can’t flank an opponent.
When in doubt about whether two characters who threaten an opponent flank it, trace a line between the two attackers’ centers. If the line passes through opposite borders or corners of the opponent’s space, then the opponent is flanked.
Exception: If a creature takes up more than one square, it gets the flanking bonus if any square it occupies counts for flanking.
Source
Core Rulebook pg. 254