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

Introduction of Thinreports for PHP

Introduction of Thinreports for PHP

PHP カンファレンス 2015 福岡で、Thinreports の PHP 実装を作ったよという話をしたときのスライド

Katsuya Hidaka

June 27, 2015
Tweet

More Decks by Katsuya Hidaka

Other Decks in Technology

Transcript

  1. ؔ٦فٝا٦أז䌘牰
    خ٦ٕ׾⡲׶ת׃׋կ
    PHP Conference FUKUOKA 2015

    View full-size slide

  2. ೔ߴ ࠀ໵
    Ruby, PHP
    Thinreports ͷ։ൃऀ

    View full-size slide

  3. SIɾσʔληϯλʔɾӡ༻ɾσʔλΤϯτϦʔ

    View full-size slide

  4. αϚϦʔ
    Thinreports ͍ͬͯ͏Φʔϓϯιʔεͷாථπʔ
    ϧ͕͢Ͱʹ͋ͬͯɺͦͷPHP൛Λ࡞ͬͨΑɺͱ
    ͍͏࿩ɻ

    View full-size slide

  5. Thinreports ͱ͸
    • Ruby Ͱ࢖͑ΔΦʔϓϯιʔεͷாථπʔϧ
    • ϨΠΞ΢τσβΠφʢEditorʣͱ

    PDFग़ྗϥΠϒϥϦʢGeneratorʣ
    • Ҏ߱͸ɺͪ͜ΒΛʮຊՈʯͱݺͼ·͢

    View full-size slide

  6. Editor
    Layout File (.tlf)
    Script (Generator)

    View full-size slide

  7. PHP ൛ Thinreports
    • Ҏલ͔Βཁ๬ଟ਺
    • Generator ͷ PHP ࣮૷
    • Editor ͸ڞ௨

    View full-size slide

  8. Editor
    Layout File (.tlf)
    Script (Generator)
    ࠓճ࡞ͬͨͷ͸ίί

    View full-size slide

  9. thinreports-php
    • Status: dev-master
    • PHP >= 5.6
    PHP7, HHVM ͸ಈ࡞ະ֬ೝ
    • The MIT License
    ଍ճΓͰ࢖ͬͯΔ TCPDF ͸ LGPLv3 Ͱ͋Δ͜ͱʹ஫ҙ
    • Pure PHP

    View full-size slide

  10. Hello thinreports-php

    View full-size slide

  11. Setup. Install thinreports-php
    $ vi composer.json
    :
    “require”: {
    “thinreports-php/thinreports-php”: “dev-master”
    }
    :
    $ composer install

    View full-size slide

  12. Setup. Install Editor

    View full-size slide

  13. 1. Create a layout file
    ID Λ “world” ΁

    View full-size slide

  14. 2. Write code
    use Thinreports;
    $report = new Thinreports\Report('hello_world.tlf');
    $page = $report->addPage();
    $page->item('world')->setValue('World');
    // ҎԼͷΑ͏ʹ΋ॻ͚Δ:
    // $page(‘world’)->setValue(’World’);
    // $page->setItemValue(‘world’, ’World’);
    // $page->setItemValues([‘world’ => ’World’]);
    $report->generate('hello_world.pdf');

    View full-size slide

  15. 3. Run
    $ php hello_world.php ↩︎

    View full-size slide

  16. ͦͷଞͰ͖Δ͜ͱ
    • ΋ͪΖΜ೔ຊޠ OK
    • ը૾ͷ੩త/ಈతషΓ෇͚
    • ਤܗɾςΩετͷಈతͳελΠϧมߋ
    • ϖʔδ൪߸ͷࣗಈදࣔ
    • ؆қॻࣜઃఆʢ೔෇࣌ࠁɺ਺஋ɺࣈ٧Ίʣ
    ͳͲͳͲɻৄࡉ͸ຊՈެࣜαΠτΛͲ͏ͧɻ

    View full-size slide

  17. ͱ͸͍͑ɺ·ͩ։ൃόʔδϣϯ
    • ϦετπʔϧະରԠ
    • ෳ߹ϨΠΞ΢τະରԠ
    ൺֱత؆୯ʹͰ͖Δɻ͜ͷޙʹͰ΋ରԠ͢Δ
    • ϑΥϯτͷϑΥʔϧόοΫະରԠ
    ͜Ε͕஍ຯʹҰ൪ͷ՝୊
    • ύϑΥʔϚϯεɾϝϞϦʔফඅͷվળ
    IPAϑΥϯτΛ TCPDF ༻ʹม׵͢Δίετ͕ߴ͍ɻࣄલʹม׵͢Δ࢓૊Έ༻ҙ
    • ςετίʔυͷΧόϨοδ 70% ͙Β͍
    ؒʹ߹Θͣ

    View full-size slide

  18. TCPDF ໰୊
    • ςετίʔυ͕ͳ͍
    ࠷ۙؾ͍ͮͨ…
    • ࠨԼʹখ͘͞ʮPowered by TCPDFʯ໰୊
    ௒ۃখαΠζˍന஍ʹനจࣈͳͷͰݟͨ໨͸໰୊ͳ͍͕…
    • PDF ϥΠϒϥϦ։ൃͱ͍͏ҋʹखΛग़͔͢೰
    ΜͰΔͱ͜Ζ

    View full-size slide

  19. ։ൃํ਑
    • ຊՈ Thinreports ͱ͸ผͷίϛϡχςΟͱͯ͠։ൃ
    ΋ͪΖΜࢲ΋ࢀՃ͠·͢
    • ϨΠΞ΢τϑΝΠϧͷ࢓༷͸ԼهͰެ։͞Ε͍ͯΔ
    ͷͰ͜Εʹैͬͯ௥ै͢Δײ͡
    https://github.com/thinreports/thinreports/wiki/Spec:-Layout-File
    • ͱ͸͍͑ɺPHP൛ಠࣗͷػೳ΋શવ͋Γ
    ͢Ͱʹ Ruby ࣮૷ͱएׯ API ҧ͍·͢͠

    View full-size slide

  20. ͥͻҰॹʹ
    • ݱࡏͷ։ൃϝϯόʔ: 1ਓʢࢲʣ
    • ͔͠΋ PHP ΛͪΌΜͱ΍Δͷ͸ 5 ೥ͿΓ
    PHPΧϯϑΝϨϯεͳͷʹ͍͢·ͤΜ
    • ΠέͯΔπʔϧʹͳΔ͔Ͳ͏͔͸ɺΈͳ͞Μ
    ʹ͔͔͍ͬͯ·͢!

    View full-size slide

  21. ૣ଎ɺ։ൃʹࢀՃ͢Δ
    • ·ͩԿ΋ߟ͑ͯͳ͍Ͱ͢
    • ͱΓ͑͋͑ͣɺGitter ͷ “dev” room ʹ JOIN
    README.md ͷԼͷํʹ͋Δɹɹɹɹɹɹɹ ɹΛΫϦοΫ͢Δ΂͠
    • ։ൃυΩϡϝϯτͳΜ͔͸ Wiki ʹ·ͱΊ·͢
    গʑ͓଴ͪԼ͍͞
    • Α͘Θ͔Βͳ͍Αɺͱ͍͏ํ͸ޙͰ௚઀ฉ͍ͯͩ͘
    ͍͞

    View full-size slide

  22. ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ
    ͪͳΈʹɺ
    • ຊՈ Thinreports v1.0 ͸೥಺ϦϦʔε༧ఆ
    • ΧελϜϑΥϯτ
    ݱࡏ࢖͑ΔϑΥϯτ͸ 4 ͭͷΈɻಠࣗϑΥϯτ͕ར༻ՄೳʹͳΔ͔΋
    • Ϧετπʔϧͷվળ
    ୯ථϨΠΞ΢τͱ࿈ථϨΠΞ΢τ͕બ୒ՄೳʹͳΔ͔΋
    • όʔίʔυػೳͷωΠςΟϒαϙʔτͳͲ

    View full-size slide