You don't give a lot of information, but I'm going to guess this is The Magicians' Guild by Trudy Canavan, which is the first book of the Black Magician trilogy.
![The Magicians' Guild](https://cdn.statically.io/img/i.sstatic.net/pbN6U.jpg)
The orphan is Sonea, and she attracts the attention of the Guild when she manages to throw a stone through the magical shield of a Guild magician:
Something flipped over in Sonea's belly, and she tightened her grip on the rock. She pulled it free and gauged its weight. A heavy one. Turning to face the magicians, she gathered the anger she felt at being thrown out of her home, all her inbred hate of the magicians, and hurled the stone at the speaker. She traced its path through the air, and as it neared the magicians' barrier, she willed it to pass through and reach its mark.
A ripple of blue light flashed outward, then the rock slammed into the magician's temple with a dull thud. He stood motionless, staring at nothing, then his knees buckled and his companion stepped forward to catch him
The Guild in principle recruits from all classes, but in practice only students from the noble houses are admitted:
Rothen shook his head and sighed as the protests continued. While there was no law forbidding the testing of children from the lower classes, the Guild sought magic in the children of the Houses only.
"The Guild hasn't taken a novice from outside the Houses for centuries," Balkan said quietly.
Some of the magicians in the Guild have purple robes, though I don't remember if all of them do.