Phalanxes are easy to counter. The AI doesn't protect them well, just oumanoeuver them, covering your moves with cavalry, and charge them on flanks and rear, avoiding every frontal impact. If they turn, SO DO YOU. Use your speed to attack every phalanx with 2 units, leaving other phalanxes uningaged but unable to support each other. In this way, when a phalanx turn, you can pull back a unit and attack phalanx's rear with the other one.

The key for me is to shatter their initial formation. Use cavalry and light troops to provoke the enemy: if you manoeuver well they will broke the formation to chase your disturbing units.