CodeIgniter: Composer

CodeIgniter: Composer

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

ใน codeinigter ว่างไฟล์ composer.json ไว้นอกสุดแต่ในไฟล์ \application\config\config.php กลับเขียน[code language=”php” title=”\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)
*/[/code]คือ พี่แกให้เก็บไฟล์ไว้ที่ application/vendor ไม่ใช่ /vendor

ปัญหานี้แก้ได้โดยเพิ่ม[code language=”javascript” title=”composer.json”]{

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

}[/code]หลังจากนั้นก็ไปเปิด auto-load โดยเปลี่ยน[code language=”php” title=”\application\config\config.php”]$config[‘composer_autoload’] = false;[/code]เป็น[code language=”php” title=”\application\config\config.php”]$config[‘composer_autoload’] = true;[/code]แล้วทดลองใช้ command[code language=”text” title=”command”]composer update[/code]จะเห็นว่าไฟล์เข้าไปที่ application/vendor แล้ว

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

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

About the author

phunsanit administrator

Leave a Reply