เดี่ยวนี้ framework ต่างๆก็ใช้ package manager อย่าง composer ติดตั้ง library ต่างๆ รวมทั้งติดตั้ง framework อื่นๆ อย่าง jQuery ถ้าต้องการที่จะสร้างโครงการของเราเองก็ทำได้ง่ายๆ
- สร้าง folder ใหม่ขึ้นมา เช่น C:\xampp\htdocs\snippets
- พิมพ์
command 1composer init
- ตอบคำถามไปตามละดับ เช่น
command 12345678910111213141516171819202122232425262728293031323334353637383940414243D:\>cd D:\xampp\htdocs\snippets
D:\xampp\htdocs\snippets>composer init
Welcome to the Composer config generator
This command will guide you through creating your composer.json config.
Package name (<vendor>/<name>) [pitt.p/snippets]: pitt/snippets
Description []: code snippets
Author [, n to skip]: Pitt Phunsanit <phunsanit@hotmail.com>
Minimum Stability []: stable
Package Type (e.g. library, project, metapackage, composer-plugin) []: project
License []: mit
Define your dependencies.
Would you like to define your dependencies (require) interactively [yes]? yes
Search for a package: jquery
Found 15 packages matching jquery
[0] components/jquery
[1] frameworks/jquery
[2] contao-components/jquery
[3] yiisoft/jquery
[4] etdsolutions/jquery
[5] ovidentia/jquery
[6] mygento/jquery
[7] quickapps-plugins/jquery
[8] intelogie/jquery
[9] apnet/jquery
[10] jquery/jquery
[11] yepsua/jquery4php
[12] venne/jquery2.0-module
[13] sonata-project/jquery-bundle
[14] blueimp/jquery-file-upload
Enter package # to add, or the complete package name if it is not listed: 0
Enter the version constraint to require (or leave blank to use the latest version):
- ตอบคำถามไปเรื่อยๆ รูปแบบ packages จะสัมพันกับ url ใน github เช่น https://github.com/jquery/jquery ถ้าไม่ทราบหาได้ขากเว้บ packagist.org จนสุดท้ายจะสร้างไฟล์ composer.json ขึ้นมา
composer.json 12345678910111213141516171819202122{
"authors"
: [{
"email"
:
"phunsanit@hotmail.com"
,
"name"
:
"pitt phunsanit"
,
"role"
:
"Developer"
}],
"description"
:
"snippet"
,
"license"
:
"mit"
,
"minimum-stability"
:
"stable"
,
"name"
:
"pitt/snippet"
,
"require"
: {
"ckeditor/ckeditor"
:
"*"
,
"components/jquery"
:
"*"
,
"components/jquery-migrate"
:
"*"
,
"components/jqueryui"
:
"*"
,
"phpoffice/phpexcel"
:
"^1.8"
,
"twbs/bootstrap"
:
"*"
},
"type"
:
"project"
}
- โหลด library โดยคำสั่ง
command 1composer update
ไฟล์จุถูกเก็บในโฟลเดอร์ vendor/xxx/yyy อย่างเรียบร้อยและเหมือนกันทุกเครื่องถ้าลง package เดียวกัน version เดียวกัน