Upgrade to Pro — share decks privately, control downloads, hide ads and more …

專案啟動與設定

 專案啟動與設定

Shengyou Fan

December 06, 2014
Tweet

More Decks by Shengyou Fan

Other Decks in Programming

Transcript

  1. ֊ஈ೚຿ • ࢖༻ composer ࢦྩݐཱҰݸ Laravel ሢҊ • ઃఆ Laravel

    ؀ڥᏓᏐ • ҆᧋ Laravel ౟݅ (generatorɺide-helperɺ faker) • ૰߹ԋ࿅
  2. 啟࢝ Laravel ሢҊ • ଧ։ cmder.exe ੾׵ࢸ ሢҊ໨㑚 • ༻

    composer ࢦྩ啟࢝ laravel ሢҊ $  cd  C:\UwAmp\www\ $  composer  create-­‐project  laravel/laravel  {your-­‐project-­‐ name}  -­‐-­‐prefer-­‐dist ˒ ჩߟɿhttp://laravel.tw/docs/4.2/installation
  3. Laravel ໨㑚݁ߏ • public ੋ Document Root • vendor ੋ

    composer ҆᧋త౟݅ • app ੋఔࣜ֩৺
  4. ྃղ composer.json {   "name":  "{vendor}/{package-­‐name}",   "description":  "{package  description}",

      "keywords":  ["{keyword1}",  "{keyword2}"],   "license":  "{license}",   "type":  "project",   "require":  {     "laravel/framework":  "4.2.*"   },        "autoload":  {                ུ...   },        "scripts":  {                ུ...        }   "config":  {     "preferred-­‐install":  "dist"   },   "minimum-­‐stability":  "stable" } ࢲ༗ሢҊ༻ɿproprietary ֨ࣜɿ"vendor/package-­‐name":  "version" ౟݅ᜦఆ౓తઃఆɿ •stable  (༬ઃ) •RC •beta •alpha •dev
  5. ᱛᨽ҆᧋ • ։啟 UwAmpɼ֬ೝ Document Root ࢦ޲ Laravel ሢҊత publicɼฒ啟ಈ

    Server • ଧ։ᖣ᧸ثɿhttp://localhost:8000 ֬ೝ ҆᧋੒ޭ
  6. .gitignore • ༗Ұࠣ䈕Ҋ (ൺํ㘸 IDE తઃఆ䈕) զ၇ෆ ૝ཁ์౸൛ຊ߇੍ܥ౷ཫɼر๬ git ՄҎ

    ࣗಈࠌུṜࠣ䈕Ҋ • ୞ཁ೺૝ࠌུతنଇሜೖ .gitignore ཫฒ commit ౸Ṷଘݿɼ೔ޙ git ब။ࣗಈࠌུ Ṝࠣ䈕Ҋ
  7. ֤։ᚙ֊ஈྲྀఔ [ development ] ։ᚙ༻ɺଌࢼ༻ [ local ] ຊػ୺։ᚙ [

    staging ] ֊ஈੑᚙ䆋 [ production ] ਖ਼্ࣜઢ 㑌ݸ։ᚙᆿ൐ຊػ୺ ᘐཱ։ᚙɼ։ᚙ׬੒ ޙૹճ൛ຊ߇੍ܥ౷ [version control] ݪ࢝ᛰ؅ཧ ఆظኺ൛ຊ߇੍ܥ౷ औग़ޙɼਐߦ੔߹ɺ ᄸݩ౳ଌࢼ ሢҊ֊ஈ׬੒ޙɼਐ ߦ֊ஈੑᚙ䆋ɼڅ٬ 㖽ଌࢼɺ֬ೝ ॴ༗֊ஈ׬੒ޙ䆋ॺ ࢸਖ਼ࣜओػɼሣ֎ެ ։࢖༻
  8. ೗Կઃఆ؀ڥᏓᏐʁ • app/config/{environment}/*.php - Laravel ။ࣗಈࠜᎦ໨લత؀ڥɼࡌೖሣ ጯతઃఆ䈕ɼ෴ሜ production తઃఆ -

    ୞धཁෳ੡धཁ෴ሜతઃఆଈՄɼᔒ༗ ઃఆతଇ။༝ production త值ትೖ - {environment} ໊᜝Մࣗఆɼୠ testing อ ཹڅᄸݩଌࢼ࢖༻ ˒ ჩߟɿhttp://laravel.tw/docs/4.2/configuration#environment-configuration
  9. ॄኄੋ Packageʁ • ࡏ։ᚙఔࣜ࣌ɼԟԟر๬ՄҎ௚઀࢖༻ผ ਓቮៃሜ޷తവࣜݿɼෆ༻ॏ৽ᚙ໌ྠࢠ • Package बੋ Laravel తᎷॆఔࣜɼಁա҆

    ᧋ Package बՄҎ௚઀࢖༻ผਓሜ޷తޭ ೳɼՃշ։ᚙ଎౓ • Ṝݸᄸݩሡ҆᧋Ꮠݸ Package ڠॿ։ᚙ
  10. Կ႔ਘፙ Packageʁ • ಁա፺ਘҾ№ਘፙɿ - Packagist - Packalyst • ᡒ

    େਆ/ಉࣄ/๎༑ తਪન • ؃ผਓత Open Source ཫ༗༻౸䬟ࠣʁ
  11. ೗Կ҆᧋ Packageʁ • ࢔ࡉ㕕ᩇ README (֬ೝ൛ຊɺن֨) • ௐ੔ composer.json /

    composer update • ઃఆ ServiceProviderɺAlias (ࢹधٻ) • Publish ઃఆ (ࢹधٻ) • Migrate DB (ࢹधٻ) ˒ Ҏ Generator ҝྫɿhttps://github.com/JeffreyWay/Laravel-4-Generators/
  12. ཁ҆᧋త Packages • way/generators - Laravel ֤छ Class 䈕Ҋ㗞ੜث •

    barryvdh/laravel-ide-helper - ኺݪ࢝ᛰ㗞ੜฤाثޠ๏ิ׬䈕 • fzaninotto/faker - 㗞ੜࢿྉݿ၊ࢿྉ࢖༻
  13. ҆᧋ֹ֎౟݅ • ฤा composer.json • ߋ৽౟݅ $  composer  update "require":

     {   "laravel/framework":  "4.2.*" }, "require-­‐dev":  {   "way/generators":  "~2.0",   "barryvdh/laravel-­‐ide-­‐helper":  "v1.11.3",   "fzaninotto/faker":  "v1.4.0" }, "autoload":  { ˒ ౟݅查ᨑɿhttps://packagist.org/
  14. ૰߹ԋ࿅ • ༻ SourceTree 啟ಈҰݸ৽తṶଘݿ • ༻ cmder + composer

    啟ಈҰݸ৽ሢҊ • ࡏ Netbeans ཫ༌ೖሢҊ • ઃఆ Laravel ٴ҆᧋ Laravel ౟݅ • ઃఆ/啟ಈ UwAmp • ᖣ᧸ثཫ༬᧸