ป้ายกำกับ: โค้ทอินิกเตอร์

CodeIgniter: ComposerCodeIgniter: Composer

โดยปกติ composer จะเก็บไฟล์โดยสร้าง folder vendor ใน folder เดียวกับไฟล์ composer.json

ใน codeinigter ว่างไฟล์ composer.json ไว้นอกสุดแต่ในไฟล์ \application\config\config.php กลับเขียน

/*
 |--------------------------------------------------------------------------
 | Composer auto-loading
 |--------------------------------------------------------------------------
 |
 | Enabling this setting will tell CodeIgniter to look for a Composer
 | package auto-loader script in application/vendor/autoload.php.
 |
 | $config['composer_autoload'] = TRUE;
 |
 | Or if you have your vendor/ directory located somewhere else, you
 | can opt to set a specific path as well:
 |
 | $config['composer_autoload'] = '/path/to/vendor/autoload.php';
 |
 | For more information about Composer, please visit http://getcomposer.org/
 |
 | Note: This will NOT disable or override the CodeIgniter-specific
 | autoloading (application/config/autoload.php) */

คือ พี่แกให้เก็บไฟล์ไว้ที่ application/vendor ไม่ใช่ /vendor

ปัญหานี้แก้ได้โดยเพิ่ม

{
 ...
 "config": {
 "vendor-dir": "application/vendor"
 },
 ...
}

หลังจากนั้นก็ไปเปิด auto-load โดยเปลี่ยน

$config['composer_autoload'] = false;

เป็น

$config['composer_autoload'] = true;

แล้วทดลองใช้ command

composer update

จะเห็นว่าไฟล์เข้าไปที่ application/vendor แล้ว

ถ้า composer โหลดไฟล์มาไม่ได้เพราะติด proxy อ่าน

อ่านเพิ่มเติม