The direct and immediate source of As You Like It is Thomas Lodge's Rosalynde, Euphues Golden Legacie, written 1586–87 and first published in 1590. Lodge's story is based upon "The Tale of Gamelyn".
As You Like It was first printed in the collected edition of Shakespeare's plays, known as the First Folio, during 1623. No copy of it in Quarto exists, for the play is mentioned by the printers of the First Folio among those which "are not formerly entered to other men". By means of evidences, external and internal, the date of composition of the play has been approximately fixed at a period between the end of 1598 and the middle of 1599.
As You Like It was entered into the Register of the Stationers' Company on 4 August 1600 as a work which was "to be stayed", i.e., not published till the Stationers' Company were satisfied that the publisher in whose name the work was entered was the undisputed owner of the copyright. Thomas Morley's First Book of Ayres, published in London in 1600 contains a musical setting for the song "It was a lover and his lass" from As You Like It. This evidence implies that the play was in existence in some shape or other before 1600.
It seems likely this play was written after 1598, since Francis Meres did not mention it in his Palladis Tamia. Although twelve plays are listed in Palladis Tamia, it was an incomplete inventory of Shakespeare's plays to that date (1598). The new Globe Theatre opened some time in the summer of 1599, and tradition has it that the new playhouse's motto was Totus mundus agit histrionem—"all the Globe's a stage"—an echo of Jaques' famous line "All the world's a stage" (II.7). This evidence posits September 1598 and September 1599 as the time frame within which the play was likely written.
In Act III, vi, Phebe refers to the famous line "Whoever loved that loved not at first sight" taken from Marlowe's Hero and Leander, which was published in 1598. This line, however, dates from 1593 when Marlowe was killed, and the poem was likely circulated in unfinished form before being completed by George Chapman. It is suggested in Michael Wood's In Search of Shakespeare that the words of Touchstone, "When a man's verses cannot be understood, nor a man's good wit seconded with the forward child understanding, it strikes a man more dead than a great reckoning in a little room", allude to Marlowe's assassination. According to the inquest into his death, Marlowe had been killed in a brawl following an argument over the "reckoning" of a bill in a room in a house in Deptford, owned by the widow Eleanor Bull in 1593. The 1598 posthumous publication of Hero and Leander would have revived interest in his work and the circumstances of his death. These words in Act IV, i, in Rosalind's speech, "I will weep for nothing, like Diana in the fountain", may refer to an alabaster image of Diana which was set up in Cheapside in 1598. However, it should be remembered Diana is mentioned by Shakespeare in at least ten other plays, and is often depicted in myth and art as at her bath. Diana was a literary epithet for Queen Elizabeth I during her reign, along with Cynthia, Phoebe, Astraea, and the Virgin Mary. Certain anachronisms exist as well, such as the minor character Sir Oliver Martext's possible reference to the Marprelate Controversy which transpired between 1588 and 1589. On the basis of these references, it seems that As You Like It may have been composed in 1599–1600, but it remains impossible to say with any certainty.