Present
Today,thePHPlanguageisquicklyevolvingandissupportedbydozensofcoreteam
developersfromaroundtheworld.Developmentpracticeshavechanged,too.Inthepast,
itwascommonpracticetowriteaPHPfile,uploadittoaproductionserverwithFTP,and
hopeitworked.Thisisaterribledevelopmentstrategy,butitwasnecessaryduetoalack
ofviablelocaldevelopmentenvironments.
Nowadays,weeschewFTPanduseversioncontrolinstead.Versioncontrolsoftwarelike
Githelpsmaintainanauditablecodehistorythatcanbebranched,forked,andmerged.
Localdevelopmentenvironmentsareidenticaltoproductionserversthanksto
virtualizationtoolslikeVagrantandprovisioningtoolslikeAnsible,Chef,andPuppet.We
leveragespecializedPHPcomponentswiththeComposerdependencymanager.OurPHP
codeadherestoPSRs—communitystandardsmanagedbythePHPFrameworkInterop
Group.WethoroughlytestourcodewithtoolslikePHPUnit.Wedeployourapplications
withPHP’sFastCGIprocessmanagerbehindawebserverlikenginx.Andweincrease
applicationperformancewithanopcodecache.
ModernPHPencompassesmanynewpracticesthatmaybeunfamiliartothoseofyounew
toPHP,ortothoseupgradingfromolderPHPversions.Don’tfeeloverwhelmed.I’llwalk
througheachconceptlaterinthisbook.
I’malsoexcitedthatPHPnowhasanofficialdraftspecification—somethingitlacked
until2014.
Note
Mostmatureprogramminglanguageshaveaspecification.Inlayman’sterms,a
specificationisacanonicalblueprintthatdefineswhatitmeanstobePHP.Thisblueprint
isusedbydeveloperswhocreateprogramsthatparse,interpret,andexecutePHPcode.It
isnotfordeveloperswhocreateapplicationsandwebsiteswithPHP.
SaraGolemonandFacebookannouncedthefirstPHPspecificationdraftatO’Reilly’s
OSCONconferencein2014.YoucanreadtheofficialannouncementonthePHPinternals
mailinglist,andyoucanreadthePHPspecificationonGitHub.
AnofficialPHPlanguagespecificationisbecomingmoreimportantgiventheintroduction
ofmultiplecompetingPHPengines.TheoriginalPHPengineistheZendEngine,aPHP
interpreterwritteninCandintroducedinPHP4.TheZendEnginewascreatedbyRasmus
Lerdorf,AndiGutmans,andZeevSuraski.TodaytheZendEngineistheZendcompany’s
maincontributiontothePHPcommunity.However,thereisnowasecondmajorPHP
engine—theHipHopVirtualMachinefromFacebook.Alanguagespecificationensures
thatbothenginesmaintainabaselinecompatibility.
Note
APHPengineisaprogramthatparses,interprets,andexecutesPHPcode(e.g.,theZend
EngineorFacebook’sHipHopVirtualMachine).ThisisnottobeconfusedwithPHP,
whichisagenericreferencetothePHPlanguage.