ããã±ã¼ã¸ç®¡çãã¼ã«ãComposerã
ãä»æ¥ã§ã¯ãå¤ãã®ããã°ã©ãã³ã°è¨èªã«ããã¦ãéçºããã¸ã§ã¯ãã«ããã±ã¼ã¸ç®¡çãã¼ã«ãæ¬ ãããªããã®ã¨ãªãã¾ããã
ãæ¢åè³ç£ã®æ´»ç¨ã§ãè»è¼ªã®åçºæããé¿ããéçºã®å¹çåãå©ãã¦ããã¾ããã¾ããã»ãã¥ãªãã£æèãé«ã¾ãä¸ã§ãå³å¯ãªãã¼ã¸ã§ã³ç®¡çã確å®ãªã¢ãããã¼ããå¼·ãæ±ãããã¦ãã¾ãã使ããããããã±ã¼ã¸ç®¡çãã¼ã«ããªããã°ãããããé ã®çãåé¡ã«ãªãã®ã§ã¯ãªãã§ããããã
ãè¨èªã«ãã£ã¦ã¯ããã±ã¼ã¸ç®¡çãã¼ã«ãæ¨æºã§æä¾ããã¦ãããã®ãããä¸æ¹ã§ãã³ãã¥ããã£ä¸»å°ã§3rdãã¼ãã£ãã¼ã«ã¨ãã¦æä¾ããã¦ãããã®ãå¤ãåå¨ãã¦ãã¾ãã
ãPHPã§ã¯ãComposerãããã¡ã¯ãã¹ã¿ã³ãã¼ããªãã¼ã«ã§ããã³ãã¥ããã£ä¸»å°ã§éçºããã¦ãããã®ã§ãããPHPãå©ç¨ããããã¸ã§ã¯ãã§ããã°ãComposerã®å©ç¨ã¯ä¸å¯æ¬ ã«ãªã£ã¦ããã¨ããããã§ãã
ãã§ã¯ãComposerã¯ã©ã®ããã«ãã¦ããã±ã¼ã¸ã®åå¨ã確èªãããã¼ã¸ã§ã³ã解決ããã®ã§ããããï¼ ãããªçåã«çããã¹ããä¸é£ã®æµãã追ã£ã¦ã¿ããã¨ããã®ãæ¬ç¨¿ã®ä¸»æ¨ã§ãã
ããªããå
容ã¯ãã¹ã¦å·çæç¹ã®ææ°çã§ããv2.8.2
ãåæã¨ãã¦ãã¾ãã
composer.jsonã¨composer.lock
ãå¤ãã®é¡ä¼¼ãã¼ã«ã¨åæ§ã«ãComposerã§ããæ§æ管çãã¡ã¤ã«ããããã¯ãã¡ã¤ã«ãã«ãã£ã¦ä¾åããã±ã¼ã¸ã管çãã¦ãã¾ãã
ãåè
ã«ãããã®ãcomposer.json
ã§ãå¾è
ãcomposer.lock
ã¨ãããã¡ã¤ã«ã§ããããããã®å½¹å²ã¯æ¬¡ã®ã¨ããã§ãã
-
composer.jsonï¼ããã¸ã§ã¯ããç´æ¥ä¾åããããã±ã¼ã¸åã¨ã許容ãããã¼ã¸ã§ã³ã®ç¯å²ãæå®ãã¢ããªã±ã¼ã·ã§ã³ï¼ããã¸ã§ã¯ãï¼ã®éçºè
ãè¨å®ãããã®ãããã±ã¼ã¸ã®è¿½å ã³ãã³ãï¼
composer require
ï¼ã«ãã£ã¦æ´æ°ããã -
composer.lockï¼ããã¸ã§ã¯ããéæ¥çã«ä¾åãããã®ãå«ãã¦ãããã±ã¼ã¸åã¨è©³ç´°ãªãã¼ã¸ã§ã³ãæå®ãComposerã«ãã£ã¦èªåçã«çæããããã®ã追å æ¸ããã±ã¼ã¸ã®ãã¼ã¸ã§ã³ã¢ããï¼
composer update
ï¼ã«ãã£ã¦æ´æ°ããã
ãä¾ãã°ãcomposer require "hoge/fuga:^1.0.0"
ã¨æå®ããããããã±ã¼ã¸hoge/fuga
ã®ãã¼ã¸ã§ã³1.x系統ã®ææ°çï¼ä¾ãã°1.27.5
ï¼ãå©ç¨ããã¾ãããã®éã«ã¯ãcomposer.json
ã«ã¯hoge/fuga:^1.0.0
ããcomposer.lock
ã«ã¯hoge/fuga:1.27.5
ãè¨è¿°ããã¾ãã
ããã®ä¾ã¯ããèªèº«ãä¾åãæããªãåä¸ã®ããã±ã¼ã¸ã®åå¾ãã¨ãã極ãã¦åç´ãªã·ããªãªã«ãªã£ã¦ãã¾ããããã§ããå解ãã¦æããã¨è¤æ°ã®ä»äºãå«ã¾ãã¦ãããã¨ã«æ°ä»ãã¾ãã
-
ããã±ã¼ã¸
hoge/fuga
ãåå¨ãããã»å©ç¨å¯è½ãã®ãã§ã㯠-
hoge/fuga
ã®å©ç¨å¯è½ãªãã¼ã¸ã§ã³ã®ãã§ã㯠-
ãã¼ã¸ã§ã³è§£æ±ºã®æ¦ç¥[1]ã«åºã¥ãã¦
^1.0.0
ã®æ¡ä»¶ã«åè´ãããã¼ã¸ã§ã³ã®ç¹å®
[1] ããã©ã«ãã§ã¯ãå®å®çãã¤ææ°çãåå¾ãã¾ã
ãããã«å ãã¦ãä¸è¬çãªComposerã®å©ç¨å ´é¢ã§ã¯ããéæ¥ä¾åãæã¤å ´åããè¤æ°ããã±ã¼ã¸å士ãåãããã±ã¼ã¸ã«ä¾åããå ´åããã¤ã³ã¹ãã¼ã«ã®åææ¡ä»¶ãæå®ããã¦ããå ´åï¼PHPã®ãã¼ã¸ã§ã³ãæ¡å¼µã®æç¡ãªã©ï¼ãçã®æ´ã«è¤éãªè¦ä»¶ãçºçãã¾ãã
ãããããåé¡ã¯ãã©ã®ããã«è§£æ±ºããã¦ããã®ã§ããããï¼ å ·ä½çãªä»çµã¿ãè¦ã¦ããã¾ãããã