PHPã¯ããšã³ããªã®ãããå€ãäœãããšã§åžžã«æåã§ããããã®çµæãå€ãã®åå¿è ããã®ããã»ã¹ãæŽçããæ¹æ³ãç解ããã«ãã¬ãŒã ã¯ãŒã¯ãç 究ãå§ããŠããŸãã OSã§äœ¿çšãããŠãããã¯ãããžãŒã®ã¹ã¿ãã¯å šäœãã€ã³ã¹ããŒã«ããŠãäœæãšå®éšãéå§ããããšããããŸãã 誀ã£ãŠã圌ãã¯ãããPHPã§æžãå§ããããä»ã®æè¡ïŒãã¬ãŒã ã¯ãŒã¯ïŒãåŠã¶æãç°¡åãªæ¹æ³ã§ãããšç€ºåããŠããŸãã
æ®å¿µãªãããã»ãšãã©ã®æç§æžã¯éçºããã»ã¹ãæŽçããæ¹æ³ãæããŠããŸããã åæ§ã«ãLaravelã¯Vagrantã®ãããã¯ã¹ããå¿ èŠãªçç±ã説æããããã®äœ¿çšæ¹æ³ã«ã€ããŠã»ãšãã©èª¬æããŸããã ãã®çµæãåŠçã¯ããŒã ã¹ãããã»ã¯ã·ã§ã³ãã¹ãããããŠãOSãç¿æ £ããå€ãããã¯ãããžãŒã圹å²ããµãŒãã¹ãæªéã®åç©åã«å€ããŸãã
æã§ïŒ
ããŒã ã¹ãããã¯ãUbuntu Serverãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ãã€ã³ã¹ããŒã«ãããŠããä»®æ³ã³ã³ãã¥ãŒã¿ãŒïŒç¬èªã®ã¡ã¢ãªãããã»ããµãŒãããŒããã©ã€ããªã©ïŒã§ããå ¬åŒã®ããªã€ã³ã¹ããŒã«ããã
ãªããããå¿ èŠãªã®ã§ããïŒ
ããã¯ãPHPäœæçšã®äœæ¥ç°å¢ãäœæããããã»ã¹ãä¿é²ããããã«å¿ èŠã§ãã PHPã§èšè¿°ãéå§ããå Žåããã¹ãŠãæ©èœããããã«ã¯ãWebãµãŒããŒãããŒã¿ããŒã¹ãPHPèªäœãªã©ãã€ã³ã¹ããŒã«ããå¿ èŠãããããšãæ¢ã«ç¥ã£ãŠããŸãã åé¡ã¯ãäž¡æ¹ã®WebãµãŒããŒãããŒã¿ããŒã¹ãèšå€§ãªæ°ã®ããŒãžã§ã³ãæ§æãªãã·ã§ã³ãªã©ãéåžžã«å€ãããšã§ãã ã€ãŸããã¡ã€ã³ã®ã€ã³ã¹ããŒã«æé ïŒã³ã³ããŒã¶ãŒã€ã³ã¹ããŒã«ïŒãå®è¡ããåããŸãã¯CMSã®ã€ã³ã¹ããŒã©ãŒãéå§ããåã«ããããçºçããã³ã³ãã¥ãŒã¿ãŒïŒãµãŒããŒïŒãæ éã«æ éã«æ§æããå¿ èŠããããŸãã 次ã«ãããã¹ã¯ãªããã1ã€ã®ããŒãžã§ã³ã®phpãWebãµãŒããŒãããŒã¿ããŒã¹ãå¿ èŠãšããå¥ã®ã¹ã¯ãªãããåäœãæåŠããä»ã®ããŒãžã§ã³ãå¿ èŠãšããå Žåã®ç«¶åã«ã€ããŠèããŸãã ãã¡ãããåãPHPãnginx'aãMySQLã®è€æ°ã®ããŒãžã§ã³ã1ã€ã®ãµãŒããŒã«ããã·ã¥ããããšãã§ããŸãããé ããæ©ãããã®åç©åã¯å¶åŸ¡äžèœã«ãªããŸãã
å¥ã®ã·ããªãªïŒãããžã§ã¯ãã§ããŒã ã¯ãŒã¯ã«ééããããã«ã¹ã¿ã ãããžã§ã¯ããéçºããäŒç€Ÿã§åãããšãè©Šã¿ãå¯èœæ§ããããŸãã ããªãããããžã§ã¯ãã«æ°ãã人ãã€ãªããšãã圌ãã¯åœŒãäœãã©ã®ããã«æ§æãããã説æããããšãæ°ã«ããããã ãããžã§ã¯ããå§ããŸãã ãããžã§ã¯ãå šäœããããã€ãããæ¢è£œã®ãµãŒããŒã«ã¢ã¯ã»ã¹ã§ããããã«ãªãããšãæåŸ ããªãã§ãã ãããããã«å€æŽãå ããããšãã§ããŸãã äŒç€Ÿã®èŠ³ç¹ããã¯ãããã¯çŸåšã®ãœãŒã¹ãšéçºãåçŽã«å䜵ããããªã¹ã¯ã§ãã ã»ãšãã©ã®å ŽåãVagrant configãæ£ç¢ºã«äžããããŸããããã¯ããã®äŸã§ã¯Laravelã®Homesteadã§ãã å¿ èŠãªãœãããŠã§ã¢ãæ§æããäœæ¥ãããããžã§ã¯ãã®æå°éšåãåŒãåºããŸãã
ãšããã§ãç§ã¯ããããã¹ãŠã·ã¹ãã ã«è² è·ããããŠããã®ã§ã¯ãªãããšããæããããã«ææããŸãã ãŸã£ãããããŸããã VirtualBoxã«UbuntuãæèŒããHomesteadã¯ãAtom z8500 \ 4GB RAMãæèŒããç§ã®äžåœèªã¿ãã¬ããã§ç°¡åã«é£ã¶ããšãã§ããŸãã
ãã¹ãŠã®èšå®ã¯æ°åã§å®äºããŸããOpenServerãã€ã³ã¹ããŒã«ããã®ãšåããããç°¡åã§ãã
ããŒã ã¹ãããã®å±éããã»ã¹ã¯ããã·ã¢ã®ããã¥ã¡ã³ãã§å®éã«ãã説æãããŠããŸãã ãŸããéçºç°å¢ã§ã®å±éãšäœæ¥ã«é¢ããããã€ãã®ãã€ã³ãã«ã€ããŠã説æããŸãã
VirtualBoxãšVagrantãã³ã³ãã¥ãŒã¿ãŒã«ã€ã³ã¹ããŒã«ãããããã®äžã«Homesteadãã©ã«ããŒãäœæãã ããã«ãããªããžããªãããã¹ãŠã®ãã¡ã€ã«ãããŠã³ããŒãããŸãã zipã¢ãŒã«ã€ããããŠã³ããŒãããå Žåã¯ãå¿ããã«è§£åããŠãã ããã
äœæ¥ç°å¢ã®å®è¡æºåã¯ã»ãŒæŽããŸãããä»®æ³ã·ã¹ãã ã«è»¢éãããã©ã«ããŒãæå®ããå¿ èŠããããŸã-ååãšããŠãããã¯ãããžã§ã¯ãã³ãŒãèªäœã®ãããã©ã«ããŒã§ãã
ãã®ãããïŒãã¹ãïŒã³ã³ãã¥ãŒã¿ãŒäžã«å¥ã®ãã©ã«ããŒïŒlaravelãªã©ïŒãäœæããŸããåŸã§ããã¬ãŒã ã¯ãŒã¯èªäœã®ãœãŒã¹ã³ãŒããäœæããããããžã§ã¯ãããã®äžã«é 眮ãããŸãã Homestead.yamlãã¡ã€ã«ãä¿®æ£ããããã€ãã®èšå®ãããã«ç»é²ãããŸãã Homestead.yamlã®äŸãã³ã¡ã³ããšãšãã«ç€ºããŸã
--- ip: "192.168.10.10" memory: 1024 cpus: 1 provider: virtualbox #Generated SSH public key authorize: C:\Users\Admin\Documents\homestead\ssh\public.pub #Generated SSH private key keys: - C:\Users\Admin\Documents\homestead\ssh\private.ppk #Sync folder folders: - map: C:\Users\Admin\Documents\laravel #on host PC to: /home/vagrant/laravel #on virtual PC #Nginx on virtual PC sites: - map: laratest.dev #server_name for nginx on virtual PC to: /home/vagrant/laravel/public #document_root for nginx on virtual PC #Create MySQL Database on virtual PC databases: - homestead
ãšããã§ãSSHããŒïŒpublic.pubããã³private.ppkïŒãçæãŸãã¯æå®ããããšã¯ã§ããŸããã 次ã«ãPuttyïŒãŸãã¯ä»ã®SSHã¯ã©ã€ã¢ã³ãïŒãä»ããŠä»®æ³ãµãŒããŒã«æ¥ç¶ããå ŽåããŠãŒã¶ãŒå\ãã¹ã¯ãŒãvagrant \ vagrantã䜿çšããŸãã
ãŸããæ§æã眮ãæããããšããå§ãããŸã
sites: - map: homestead.app
ã«
sites: - map: laratest.dev
ããã¥ã¡ã³ãã®ããã«ããã©ã«ãã®homestead.appã¢ãã¬ã¹ã®ãŸãŸã«ãããšãç§ã®ã¯ãã ã¯èšã£ãïŒ
çµç¹ãŸãã¯åŠæ ¡ã®ã€ã³ãã©ãããäžã®ãã®ãµã€ãã«ã¯ãã€ã³ã¿ãŒãããäžã®ãµã€ããšåãURLããããŸãã
以äžã®Homestead.yamlã«ã¯ãã³ã¡ã³ãåãããããŒãã®ã»ã¯ã·ã§ã³ãããããšã«æ³šæããŠãã ããã ããã¯ãä»®æ³ã·ã¹ãã ãšã®éã§ããŒãã転éããã®ãç°¡åãªããšã§ãã ãã®ã»ã¯ã·ã§ã³ã¯ã³ã¡ã³ãåãããŠããŸãããHomesteadã¯ããã©ã«ãã§ããã€ãã®ããŒããå®éã«è»¢éããŸãã runã³ãã³ããå®è¡ãããšãããã«é¢ããã¡ãã»ãŒãžã衚瀺ãããŸãã
éå§ããã«ã¯ãHomesteadãã©ã«ããŒã«ç§»åããShiftããŒãæŒããªããããŠã¹ã®å³ãã¿ã³ãæŒãã[ã³ãã³ããŠã£ã³ããŠãéã]ãªãã·ã§ã³ãéžæãããšãHomesteadãã£ã¬ã¯ããªã«æ¢ã«ã移åãããã³ã³ãœãŒã«ã衚瀺ãããŸãã æ瀺ã«åŸã£ãŠæµ®æµªè ãäœæããŸãã Vagrantãçªç¶ãšã©ãŒãåºããŠãå¿é ããªãã§ãã ãããVirtualBoxãŸãã¯Vagrantã®ææ°ããŒãžã§ã³ããæã¡ã§ãªãå¯èœæ§ããããŸãã ãããã«ããããšã©ãŒã®èª¬æãã°ãŒã°ã«ã§æ€çŽ¢ããŠãã ãããååãšããŠã解決çã¯Vagrant'aã®* .rbãã¡ã€ã«ãç·šéããããåã€ã³ã¹ããŒã«ããããšã§ãã ããšãã°ãææ°ã®ãã°ã®1ã€ã§ãããserver_version.rbïŒ54ïŒin` readpartial 'ïŒç¢ºç«ãããæ¥ç¶...ãã¯ããã§è§£æ±ºãããŸã ã
ãã¹ãŠãæ£ããè¡ãããå ŽåãHomesteadãã£ã¬ã¯ããªããvagrant upã³ãã³ããå®è¡ãããšãVagrantã¯Ubuntaã䜿çšããŠä»®æ³ã·ã¹ãã ã®ã€ã¡ãŒãžãããŠã³ããŒãããããã«ãœãããŠã§ã¢ã®å šãªã¹ããã€ã³ã¹ããŒã«ããHomestead.yamlãã¡ã€ã«ã«ç»é²ãããã®ãå¿ããã«æ§æãä¿®æ£ããŸãã æçµçã«ããMachine booted and readyïŒããšãã©ã®ããŒãã転éããããã«æºè¶³ããŸãã
次ã«ãOSããæ°ã«å ¥ãã®ãã©ãŠã¶ãŒããšãã£ã¿ãŒã§éåžžã©ããäœæ¥ããŸãã ååãšããŠããã·ã³ã«ä»ã®ãœãããŠã§ã¢ãä¿æããå¿ èŠã¯ãããŸããã å¿ èŠãªãã®ã¯ãã¹ãŠããã§ã«ä»®æ³ç°å¢ã«ãããŸãã Puttyã䜿çšããŠæ¥ç¶ããŸãïŒäžèšã®ã¹ã¯ãªãŒã³ã·ã§ããã®ããã«ãæ¥ç¶127.0.0.1ãããŒã2222ã®ã¢ãã¬ã¹ãæå®ããŸãïŒã
cdã³ãã³ãã䜿çšããŠããããžã§ã¯ããã©ã«ããŒïŒHomestead.yamlã§æå®ãããïŒã«ç§»åããŸãã
ããã«ã¯æ¢ã«ãã¡ã€ã«ããããŸããããã®ãã©ã«ããŒã¯ç©ºã«ãªããŸãã ãããåããæéã§ãã ãã¹ãã®Windowsãã·ã³äžã®ãã©ã«ããŒã¯ãUbuntuã®ããä»®æ³ãã©ã«ããŒãšèªåçãã€ç¬æã«åæãããŸãã ãã¡ã€ã«ã¯ããŠã£ã³ããŠãšubuntuã®äž¡æ¹ã§èªã¿æžãã§ããŸããã€ãŸããåæ¹åã®åæã§ãã
Windowsã§äœæ²å®¶ãgitã³ã³ãœãŒã«ãã€ã³ã¹ããŒã«ããããšããªãã§ãã ãã:) ããŸãã Windowsã§ã¯ OpenServerãxampãdenverãªã©ã®ãã«ãã䜿çšããªãããšã匷ããå§ãããŸã ã
ä»®æ³ãµãŒããŒäžã®ç®çã®ãã©ã«ããŒã«ç§»åãã ããã¥ã¡ã³ãã®æ瀺ã«åŸã£ãŠãã ããã ä»®æ³ç°å¢ã§ã¯ããã§ã«gitãšcomposerãã€ã³ã¹ããŒã«ãããŠããŸãã
ãã ãã£ãŠãã€ããã§äœ¿ã£ãŠãã ããïŒ
ããããå°æ¥ãWebãããžã§ã¯ãã®éçºããã»ã¹ãé©åã«æŽçããæ¹æ³ïŒPHPãLaravelãèæ ®ã«å ¥ããïŒãLaravelã§äœæ¥ããããã®IDEãæºåããæ¹æ³ãGitã§äœæ¥ãæŽçããæ¹æ³ãgitãããããžã§ã¯ãã®å±éãèªååããæ¹æ³ã«ã€ããŠã話ããŸãæ¢åã®ããŒã«ã䜿çšããŠãµãŒããŒãéçºããŸãã éçºãµãŒããŒããã®ãããžã§ã¯ããšããŠã®å¥ã®ãããã¯ã¯ãéçšãµãŒããŒã«ã¹ã ãŒãºã«å±éãããŸãã
ãããã¯ãã¹ãŠåºå€§ã§èå³æ·±ããããã¯ã§ãããæåã«éçºç°å¢ãä»®æ³åããæåŸã«Windowsãžã®PHPã®ã€ã³ã¹ããŒã«ãåæ¢ããŸãã