ZendFramework2 源碼分析 init_autoloader.php

來源:互聯網
上載者:User

標籤:style   blog   io   ar   color   os   sp   for   strong   

 1 // Composer autoloading 2 if (file_exists(‘vendor/autoload.php‘)) {
// 載入自動載入器
3 $loader = include ‘vendor/autoload.php‘; 4 } 5 6 if (class_exists(‘Zend\Loader\AutoloaderFactory‘)) {
    // 如果已經載入過了直接返回
7 return; 8 } 9 10 $zf2Path = false;11 12 if (is_dir(‘vendor/ZF2/library‘)) {
    // 預設的架構路徑
13 $zf2Path = ‘vendor/ZF2/library‘;14 } elseif (getenv(‘ZF2_PATH‘)) { // Support for ZF2_PATH environment variable or git submodule

    // 根據環境配置擷取架構路徑(大寫)15 $zf2Path = getenv(‘ZF2_PATH‘);16 } elseif (get_cfg_var(‘zf2_path‘)) { // Support for zf2_path directive value

    // 根據環境配置擷取架構路徑(小寫)17 $zf2Path = get_cfg_var(‘zf2_path‘);18 }19 20 if ($zf2Path) {21 if (isset($loader)) {
       // 在定義了自動載入器的情況下自動載入
22 $loader->add(‘Zend‘, $zf2Path);23 $loader->add(‘ZendXml‘, $zf2Path);24 } else {
       // 引入載入器
25 include $zf2Path . ‘/Zend/Loader/AutoloaderFactory.php‘;26 Zend\Loader\AutoloaderFactory::factory(array(27 ‘Zend\Loader\StandardAutoloader‘ => array(28 ‘autoregister_zf‘ => true29 )30 ));31 }32 }33 34 if (!class_exists(‘Zend\Loader\AutoloaderFactory‘)) {
// 載入器載入失敗拋出異常
35 throw new RuntimeException(‘Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.‘);36 }

 

ZendFramework2 源碼分析 init_autoloader.php

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.