A bloodrager that's wearing a ring of vengeful blood magic can 3/day while in a bloodrage cast a spell as an attack of opportunity. The spell must have a casting time of 1 standard action or less and either target or include in its area the creature that provoked an attack of opportunity from the bloodrager. The ring has a price of 5,400 gp.
A generous GM may allow any creature to use the ring if that creature first succeeds on a Use Magic Device skill check made to emulate the level 1 bloodrager class feature bloodrage (DC 20) to convince the ring that the user is in a bloodrage—sort of like how Lidda convinces the magic chalice that she activated it using a turn undead attempt she didn't have, an example in the Player's Handbook (2003) description of the skill Use Magic Device (86). (This example is absent from the Dungeons & Dragons 3.5 SRD, therefore it's also absent from Pathfinder.) However, this is far from a sure thing, and the GM should be consulted about this process before the nonbloodrager PC buys a ring of vengeful blood magic.
Other than this magic item, I think a player's left asking the GM if 3.5 feats can be adapted to Pathfinder. For example, the metapsionic feat Opportunity Power (Expanded Psionics Handbook 48-9) could serve as a template for a similar Pathfinder metamagic feat, as could the epic feat Spell Opportunity (Epic Level Handbook 67).
Note: Casting spells is already the game's most powerful ability, and that ability is made even more powerful if the caster can cast spells A) when it's not the caster's turn, and B) without the caster needing to expend her normal actions. A GM would be wise to strictly limit any adapted or homebrew ability of a caster to cast spells as an attack of opportunity.