Phalanxes are invincible from the front. Plain and simple. The only thing that can hurt a phalanx from the front is another phalanx. Don't use your infantry to assault from the front. No point. Use the AI's stupidity against it, and just change direction before you even reach it. Of course, in multiplayer it won't ever happen, but you can just have your infantry run past their flank and then charge. Or, do that with slingers and archers, run past them and then fire as much crap at their backs as you can.