1. 自动加载器与Composer

自动加载器

drupal8龤龡龟龛龚龖龒龑龐龌龉龡龇龃齿齾龉龡龇龃齿龑齻齷齵齴齳齯龑齬齷齫齧龟齳

齦齤齢齡齞龟php齚齖齒齎龟齍齉齾齅齃鼿鼻龚鼹鼸齡齞鼷鼳齅鼲龇龃鼸鼯鼬鼨鼧齾鼤php齎鼡鼠鼞鼚鼖鼕鼸鼯鼬鼨鼧齍齾鼠鼑鼏鼍鼋鼊鼇齾齯鼏鼄龚鼹鼀黿黾齤黻黹黸黷黾齤鼯鼬龟黵黲黯黮黪黦齾黤黢齦黟鼹黛齚默鼸鼯鼬鼨鼧黕龇龃黒齾鼷黎黋黇黆齃鼿鼻齡齞齾齚齖黃麿鼞鼚麼麺龟黇黆麹麵齾麳鼷齚齖鼊鼇齾麱齷黟鼹鼀黿黾齤龟黵黲黯黪黦龑齬齷麭龟麩齳齯龑麦黷麥鼯鼬麣齾麠麟麛黛spl_autoload_register麆麂鹾鹼鹺鼄龟齾黟龒龑php龟龉龡龇龃鹹鹸齾spl_autoload_register麆麂龟鹶黷黪黦鹳鹯 http://www.php.net/manual/zh/function.spl-autoload-register.php

drupal8龒鹶黷黒黟鼹龉龡龇龃鹹鹸齾齦齃鼿鼻鹓鼹齡齞龟齍齉齾php麛黛鼸龟鹐鹏鹋鼯鹊鹆麆鹄鹊鹂鸿鸻鸷鸶龟鼸鹊麂鸵鼨鼧鸳鸰龟齡鸭鸪鸩龉龡鼄 include鼨鼧齾黟鼹鸥鸡黕鸞鸛齦龚鼹齡齞黾齤鹐鸘齾黟鼹齡齞龟鼸鼯鼬鼨鼧鸕鸓\vendor\composer\ClassLoader.php

齦\vendor\composer\鼨鼧鸄鸂鸀鼏鷿鸵黤鸂鷻鼹鼨鼧鷸

autoload_classmap.php 黾齤龑鼸鸵鼸鼯鼬鼨鼧龟鷴鷰鸪鸩鷯

autoload_files.php 黾齤龑鹏鷬鼳齅龇龃龟黵黲

autoload_namespaces.php 黾齤龑 PSR0 鷴鷰鸪鸩

autoload_psr4.php 黾齤龑 PSR4 鷴鷰鸪鸩

ClassLoader鼸齡齞龒龑鷟鷜黾齤鼯鼬龟鷘鷗齡鸭鸪鸩鼄鷖鷔黵黲鷓鼸鼯鼬鼨鼧齾齦齚齖鷐麵麟鷍黃麿龡鷌龟鷋龇黟鷊鷴鷰鸪鸩鹺鼄

齃鼿鼻龇龃齿麟麆齃鼿鼻黛齚默鷉鷆齢spl_autoload_register鹾鹼黒麂齾drupal8龒鼑鼳齅鷅龡龟 include龚鷂鶿鼨鼧黒齾鶼鼄黒鷂鶹鸥鸡齾鶸鸵黟黾鸀鸭鶴鶱鶰黒齻齷龑龉龡龇龃齿鷓齯龟鶭鶩鶧

黤黢鸀鷿黛drupal8龟index.php鼨鼧黃鶡鼏鶠鶜鶛齻齷齅默鶘鷻黹鶖鸵\vendor\composer齾鶔齃龑鶐鶛\vendor\composer黾齤龟鼨鼧龑龉龡齧鸘龟齾鶍鶉\vendor鶅鶁黾齤龟鶀鼚鼨鼧鵿龑龉龡齧鸘龟麆vendor黾龑drupal8黷鸵龟鶀鼚龛鵼黪齚齖鵻麂齾黟龑齬齷黋鵹齳龑鵶齧鸘黒鵲鵱齳鵯龒龑鷂鹊鵫鵫龟composer

Composer

composer黕黷鸓php齚齖龟黻鵨鵦鶩齾鵢鵡鵝鶸龒龑鼡鵚php鵘鶅黯鵖黯鵔鼏黷鸵龛鵼黪齚齖鵻齾麱齷黤鵑鵐鵏龛鵼黪鵻龟鵎鵌齳黤鵑鸂龃齳鵖鼹鵉鸡黮黤鵑鵐鵏鵆鷗鵃龚齳龛鵼黪鵻鵂鵁鵀黻鵨黯鵖鴼黻鵨齬齷鴺鶩齳黟鼳齅龚鼹龉龡鼻龟鴶鴲黪鴯齾鸓龑composer齫齧黒

composer黷鸓鴶鴲鴮鴬麼麺齾齯鷗鴨龑龚鼹黷php鴧鸘龟鸭黷齚齖齾黕鸞鸛鸘黒composer.phar齾鷐麵齦php鴤鴮齾鴢鴡鸀鸂龃龛鵼黪鴝鼧鵻齾鵐鵏鵆鷗鵃龚齾齫齧龉龡龇龃齿龟鴜鵚鴙鴗鴗齾drupal8龟\vendor鶅鶁龒龑鵲龉龡齫齧龟鶧鸂齤鴔鵱麭鴓鴐龚鸂齯龟黷黦鷸

鼲鴌鸛composer齾鶀鴊鴌鸛鶔齃龒龑鸂龃齯龟麹麵鼨鼧composer.phar齾黤黢鼳齅黪鴉龚鵝鴅鴃齯龇鴀鳼鸡鸩鵃龟鳺鳹鳶鶹齾黟黾鶛鳵鴬黪鴉齾鳱鼯鸀鹶黷龟龑window鸩鵃齾php鷉鷆黕鷋龇鸵鳺鳹鳶鶹默齾composer.phar鳯鼳鷋龇鸵鳺鳹鳶鶹默齾齃鳬鶅鶁鶛C:\root\test\composer鷸

鳨鼲鸂龃composer.phar齾 鳤鳠 鼚鷻鷊鴌鸛黪鳝齾黃麿黷鳚鳗麵鴌鸛齾鳔黃麿鳓鳏鸂龃齾鳎齒 https://getcomposer.org/download/ 鷖鷿鳊齤鳆鳃齾Manual Download鷅龡鸂龃齾鲾鲼鲻鵌龟龚鼹鵆鷗齾鸂龃鵐鲺鸵C:\root\test\composer默鶧

composer龑麛黛composer.json鼨鼧麭鴶鲲鼠龉龡鸂龃龛鵼黪鵻龟齾鸂龃鹐鸘鼏齧鸘龚鼹composer.lock鼨鼧齾黷鸓鲪鼯鵉鲩齒齎黮龟龛鵼黪鵆鷗齾鸪鸓composer.json齬齷鹸鸡麱龑鹶黷龛鵼黪鵻龟鵘鶅齒齎黮龟鲦鲣齾鹳鲡鲟鳤黪鼨鲜齾黟黾鲛鹸drupal8鲗鶅鶁龟composer.json鲓composer.lock鲓core鼨鼧鸄鸵C:\root\test\composer默齾鳎齒鳚鳗麵,齒鲍鲌鵡>cmd鹳鲈鵐php黕鷋龇鸵黒鸩鵃鳺鳹鳶鶹齾鷐麵鲄鴡鲀鱽鱻龟鳚鳗鷸

鶍齍齚齖齒鲍鸂龃龛鵼黪鵻齾鼠齫齧龉龡龇龃齿齾鵖鱺龚鼹C:\root\test\composer\vendor鶅鶁齾鹺鼄鷿龚鷿齾齡鱷龚鸂鸓drupal8鲗鶅鶁鸂齤龟\vendor龑鼑龑龚鱶龚鱵麩齳

鸪鸓composer龟鵎鵖鱱鱮鹳鸵鳤黪鳠鱪 https://getcomposer.org/

    cd C:\root\test\composer  
    php composer.phar  install 

晴空注:关于Composer的延伸阅读资料:

 

D.O.: Using Composer with Drupal

Pantheon:Using Drupal 8 and Composer

Jeff Geerling:Tips for Managing Drupal 8 projects with Composer 及 

Composer and Drupal are still strange bedfellows

本书共71小节:

评论 (写第一个评论)