According to the Oxford English Dictionary, directly can be used colloquially as a conjunction:
colloq. as conj. As soon as, the moment after. (Elliptical for directly that, as, or when.)
The examples they give include:
1795 Montford Castle I. 88 Directly you refused [his] assistance, a judgement overtook you.
1827 R. H. Froude Remains (1838) I. 68, I quite forget all my scepticism directly I fancy myself the object of their perception.
There is some discussion of this conjunction here, which noted:
So this use of directly is a Britishism. Similar words are immediately and instantly. Not all adverbs function as conjunctions, however, and there was debate about how proper such a use is (Dickens used them, but dictionaries didn't like the construction--note that the OED still calls it colloquial). The book mentioned above also notes that it is possible that any adverb could become a conjunction, so future uses of adverbs cum new conjunctions could occur:
The book notes that once and directly were being adopted at time of writing. Only once seems to have taken hold ("I'll be with you once I do XYZ") while directly remained a mostly British usage.
On formality, the Cambridge Dictionaries Online note that the phrase is slightly formal or formal, depending on how the conjunction is used.