During the lifetime of the Prophet .
A study of the compilation of text must begin with the character of the book itself as it was handed down by Prophet Muhammad to his Companions during his lifetime. It was not delivered or revealed all at once.
The Noble Quran was revealed to Prophet Muhammad piecemeal over a period of twenty-three years from the time when he began to preach the Message of Islam in Makkah in 610 CE until his death at Madeenah in 632 CE. The Quran itself declares that Allah addressed Prophet Muhammad with what means: "…And We have spaced it distinctly." [Quran 25:32]
Furthermore, no chronological record of the sequence of passages was kept by Prophet Muhammad himself or his Companions so that, as each of these began to be collected into an actual Soorah (chapter), no thought was given as to theme, order of deliverance or chronological sequence. It is acknowledged by all Muslim scholars that most of the chapters, especially the longer ones, are composite texts containing various passages not necessarily linked to each other in the sequence in which they were given. As time went on Prphet Muhammad would say words to the effect of: "Put this passage in the chapter in which so-and-so is mentioned", or: "Put it in such and such a place." [Imam As-Suyooti, Al-Itqan fee 'Uloom Al-Quran, p.141] Thus, passages were added to compilations of other passages already collected together until each of these became a distinct chapter. The evidence that a number of these chapters already had their recognised titles during the lifetime of Prophet Muhammad is the following two Prophetic narrations: "Anyone who recites the last two verses of Soorah Al-Baqarah (The Cow, chapter 2) at night, they will suffice him." [Al-Bukhari] And: "If anyone learns by heart the first ten verses of the Soorah Al-Kahf (the Cave, No. 18), he will be protected from the Dajjal (Antichrist)." [Imam Muslim]
At the same time, there is also reason to believe that there were other chapters to which titles were not necessarily given by Prophet Muhammad . An example of this is Soorah Al-Ikhlas [Chapter 112], for although the Prophet spoke at some length about it and said it was equal to one-third of the whole Quran, he did not mention it by name. [Imam Muslim]
As the Quran developed, the Prophet's Companions took portions of it down in writing and also committed its passages to memory. It appears that the memorisation of the text was the foremost method of recording its contents as the very word Quran means 'recitation'. From the very first word delivered to Prophet Muhammad by the angel Jibreel (Gabriel) on Mount Hiraa', namely Iqra'a – 'Recite!' [Chapter 96:1], we can see that the verbal recitation of its passages was very highly esteemed and consistently practiced. Nevertheless, it is to actual written records of its text that the Quran itself bears witness in the following verse (which means): "[It is recorded] in honoured sheets. Exalted and purified. [Carried] by the hands of messenger-angels. Noble and dutiful"[Quran: 80:13-16]
Furthermore, there is evidence that even during the early days of Prophet Muhammad in Makkah, portions of the Quran as then delivered were being written down. When 'Umar was still a pagan, he one day struck his sister when he heard her reading a portion of the Quran. Upon seeing blood on her cheek, however, he relented and said: "Give me this sheet which I heard you reading just now so that I may see what Muhammad has brought." [Ibn IsHaq, Seerat Rasoolullah, p.156]. On reading the portion of Soorah Taha (the twentieth chapter of the Quran) which she had been reading, his mind was changed and he became a Muslim.
Nonetheless, it appears that right up to the end of the life of Prophet Muhammad the practice of memorisation predominated over the writing down of the Quran and was regarded as more important.
In the Hadeeth (Prophet's narrations) records, we read that the angel Jibreel is said to have checked the recitation of the Quran every Ramadan with Prophet Muhammad and, in his (the Prophet ) final year, Jibreel checked it with him twice. Fatimah, may Allah be pleased with her, said: "The Prophet, sallallaahu alayhi wa sallam, told me, 'Jibreel used to recite the Quran to me and I to him once a year, but this year he recited the whole Quran with me twice. I think that my death is approaching.'" [Imam Al-Bukhari]
Some of the closest Companions of the Prophet devoted themselves to learning the text of the Quran by heart. These included Ubayy Ibn Ka'ab, Mu'ath Ibn Jabal, Zayd Ibn Thabit, Abu Zayd and Abu Ad-Dardaa' . Abdullah Ibn Mas'ood collected more than ninety of the one hundred and fourteen chapters by himself, learning the remaining chapters from other Companions.
Regarding the written materials, there are no records as to exactly how much of the Quran was written down during the lifetime of Prophet Muhammad . There is no evidence to suggest that anyone actually compiled the whole text of the Quran into a single manuscript, whether directly under the authority of Prophet Muhammad or otherwise.
The revelation of the Quran ended with the death of Prophet Muhammad in 632 CE, as the Quran had become complete. There could be no further revelation once its chosen recipient had passed away. While he lived, however, there was always the possibility that new passages could be added and it hardly seemed appropriate, therefore, to contemplate codifying the text into one harmonious whole. Thus, it is not surprising to find that the book was widely scattered in the memories of men and in writing on various different materials at the time of the death of the Prophet .
There were only a few disputes among the Companions about the text of the Quran while the Prophet was alive, unlike those which arose soon after his death. All these factors explain the absence of an official codified text at the time of his death. Imam As-Suyooti stated that the Quran, as sent down from Allah in separate stages, had been completely written down and carefully preserved, but that it had not been assembled into one single location during the lifetime of Prophet Muhammad, sallallaahu alayhi wa sallam, [Ibn Ishaq, Seerat Rasoolullah, p.96]
All of it was said to have been available in principle, for the Companions had absorbed it in their memories and it had been written down on separate materials. The final order of the various verses and chapters is also presumed to have been defined by the Prophet while he was still alive.