Let's open source!!

自我介紹

  • Peter (李昀陞)

  • GitHub

  • 目前在ITRI服務

  • 後端開發者

  • 3+ years PHP 後端程式開發

  • PHP 5.3 → PHP 7+

  • No framework→Slim→Laravel

  • 2 years 開源專案貢獻者

  • LaravelConf 2018, COSCUP 2018 講者

Outline

  • 自我介紹

  • 什麼是開源專案?可以吃嗎?

  • 開源貢獻包含了哪一些?

  • 我怎麼入坑的?

  • 學習到的 Modern PHP 技巧

  • 多人開發心得 & 有趣的事情

  • 介紹國外的開源貢獻活動

Survey

What's open source project?

什麼是開源專案?

以開源專案許可下公開的專案

  • MIT License
  • GPL/GNU
  • Apache Licenese
  • etc.

什麼是開源專案貢獻?

開源貢獻活動

  • Issue submission
  • Send pull request
  • etc.

Issue submission

Report bugs

Feature requests

Official docs

Send pull request

  • 在發送issue之後
  • 也可以直接發送 PR

開源貢獻流程

  • 發送 issue → 發送 PR
  • 直接發送 PR

開源貢獻好處

  • 學習技巧
  • 線上多人合作
  • 看code能力提升,再爛code都可以看
  • 幫助別人,也幫助自己
  • 不用加入公司,也可以對他們開源專案做貢獻

我是怎麼入坑的?

事情是這樣的...

當時的社群機器人很夯

我想做個問天氣機器人

我找到了bug...並發送PR

Bug

Bug

第一次就不會發送PR

還開了很多個PR...

還被指教了一番

最後還是被merged了

第一次 PR 我學會了...

  • Squash all commits to one commit
  • Explain for the changes
  • Accept request changes

等一等...

那個問天氣機器人呢?

去開源貢獻了!

不要問我問天氣機器人在哪!

因為我也不知道XD

我學到的Modern PHP技巧

從四個種類角度切入

Enhancement
Features
Fix bugs

Write docs

Enhancement

Test enhancement

Test enhancement tips

$this->assertSame(true, $resultTrue);

$this->assertSame(false, $resultFalse);

$this->assertSame(\InvalidgrumentException::class, 
    $resultInstance);

$this->assertSame(23, count($resultArray));

$this->assertInstanceOf('\\Psecio\\SecureDotenv\\KeySource\\KeyString',
    $k);

Test enhancement tips

$this->assertTrue($resultTrue);

$this->assertFalse($resultFalse);

$this->assertInstanceOf(\InvalidgrumentException::class, 
    $resultInstance);

$this->assertCount(23, $resultArray);

$this->assertInstanceOf(KeyString::class, $k);

Test enhancement tips

Test enhancement tips

Organize src

Organize src

Organize src

Add more tests

Add more tests

Add more tests

Features

Add isPrimeNumber method

Add isPrimeNumber method

Initialize tests

Initialize tests

Fix bugs

oscarotero/imagecow

oscarotero/imagecow

oscarotero/imagecow

oscarotero/imagecow

oscarotero/imagecow

jwage/easy-csv

jwage/easy-csv

jwage/easy-csv

jwage/easy-csv

return
    (isset($this->headers) && is_array($this->headers)) 
    && (count($this->headers) !== count($row))
    ? $this->getRow() : array_combine($this->headers, $row);

jwage/purl PR#60

jwage/purl PR#60

jwage/purl PR#60

URI = scheme:[//authority]path[?query][#fragment]

jwage/purl PR#60

jwage/purl PR#62

jwage/purl PR#62

Write docs

odan/image

odan/image

odan/image

odan/image

odan/image

danielgsims/php-collections

danielgsims/php-collections

danielgsims/php-collections

Review PR

m1/Env

m1/Env

m1/Env

難→易

  1. Enhancement

  2. Features

  3. Fix bugs

  4. Write docs

貢獻前需要知道的事

貢獻步驟

  • Create issue (option)
  • Fork it
  • Read the CONTRIBUTING.md
  • Create and checkout a branch
  • Add the code
  • Send PR

CONTRIBUTING.md

Coding style

.php_cs

PHP_CodeSniffer

curl -OL \
    https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar

php phpcs.phar --standard=PSR2 src/ tests/ --colors

Continuous Intergration

CI

Travis CI/.travis.yml

StyleCI/.styleci.yml

合作的機會

成為Collaborator

和國外開發者們一起成長

介紹國外的開源貢獻活動

Hacktoberfest

Hacktoberfest

Hacktoberfest 2018

Hacktoberfest 2018

Contribute SenGrid Repos

Earn Special T-Shirt

達成條件

Our documentation repo all have issues labeled with “hacktoberfest” and a size.

Contribute 5 difficulty: easy or 2  difficulty: medium or 1 difficulty: hard or greater to receive swag kit.

我又超過條件了....

  • https://github.com/sendgrid/php-http-client/pull/120

  • https://github.com/sendgrid/sendgrid-php/pull/735

  • https://github.com/sendgrid/sendgrid-php/pull/720

  • https://github.com/sendgrid/sendgrid-php/pull/715

Summary

  • 沒有最好,只有比較好
  • Accept request changes
  • 開源貢獻是多人合作的經驗

Summary

  • 被人幫助,幫助別人

  • 別人的感謝是繼續貢獻動力

  • 讓開源專案更好

  • 做國民外交

別人的感謝是繼續貢獻動力

別人的感謝是繼續貢獻動力

多人合作

線上跟國外開發者們交流

Any questions?

Let's open source!!

By peter279k

Let's open source!!

MOPCON 2018 unconference talk slide link: https://bit.ly/2SJDcoU

  • 1,346