In 1702 Scarlatti left Naples and went to Florence where he composed operas for Ferdinando de ' Medici and for Cardinal Ottoboni , who made him his maestro di cappella . In 1703 he also got a similar job in Rome at the Basilica di Santa Maria Maggiore . In the interval he enjoyed the patronage of Ferdinando de ' Medici , for whose private theater near Florence he composed operas , and of Cardinal Ottoboni , who made him his maestro di cappella , and procured him a similar post at the Basilica di Santa Maria Maggiore in Rome in 1703 .