The Battle AI is generally programmed to avoid phalanx capable units unless they have their own phalanx units. So if you are facing euro-barbs, best bet is to take a long phalanx line and a bunch of missiles with strong flank protection. They will advance and scatter towards your flanks while you pick them off with missiles.

Fighting phalanxes is easy as well. Hoplites are pretty bad at it because they are meant as defensive units rather than offensive ones. But even poor AP or high lethality units like Anatolian Hillmen and the like can eat into the side of a levy phalanx with minimal casualties. Of course hammer and anvil with cavalry works best though.