To use a phalanx offensively you have to march it in a line straight through the enemy line. Stop once you make contact and watch while your enemy tries to reach your troops. This is when you send your best flankers around the side to rout the enemy. I often use thracian mercs for this. If nothing else spartans are also great for it.