$30 off During Our Annual Pro Sale. View Details »

Phing - An Introduction (phpDublin June 2015)

Phing - An Introduction (phpDublin June 2015)

Slides for a 30 minute talk by @kenguest on phing - the multi-platform, ant based, PHP build tool. Given at @phpDublin's June 2015 meeting.

Ken Guest

June 23, 2015
Tweet

Other Decks in Programming

Transcript

  1. @phpdublin
    Who am I?
    Ken Guest
    https://about.me/kenguest
    Twitter @kenguest
    Web Developer at the Irish Times
    PEAR guy
    Services_OpenStreetMap
    15 years of developing projects in PHP.

    View Slide

  2. And what is Phing?
    PHing Is Not Gnu make
    https://www.phing.info/
    A cross platform build tool written in PHP.
    Automation.
    Gear yourself for efficiency.
    DRY v WET.
    @phpdublin

    View Slide

  3. And what can Phing do?
    Lint your code (php, javascript, xml)
    Run unit tests: phpunit, simpletest, behat
    Codesniffer
    Copy and Mess detectors
    Optimise images
    Minify javascript/css
    Transfer files (rsync, ftp, scp)
    Database migrations (dbdeploy, pdosqlexec)
    Modify ini files natively
    Git, SVN tasks
    Etc
    And it's in PHP?
    Yes. You can create custom tasks.
    @phpdublin

    View Slide

  4. What projects use it?
    joind.in
    OpenDAM (Digital Asset Management - https://github.com/martin-wikipixel/openDAM)
    Semantic Scuttle (social bookmarking)
    And many others
    https://github.com/reload/phing-drupal-template
    How to use it?
    From phpStorm, TextMate or NetBeans 8.1
    From command line
    From Continuous Integration: Jenkins, Travis etc
    @phpdublin

    View Slide

  5. @phpdublin

    View Slide

  6. @phpdublin

    View Slide

  7. @phpdublin

    View Slide

  8. Obligatory Hello World example:



    Hello



    @phpdublin

    View Slide

  9. @phpdublin
    Example with Dependencies:




    Banner


    Hello



    $ phing banner
    $ phing hello
    $ phing

    View Slide

  10. @phpdublin
    Native Tasks



    Hello..?
    Hello



    View Slide

  11. @phpdublin
    Something more meaty:





















    View Slide

  12. @phpdublin
    Native Tasks v 'Exec'

    Compared to

    Tonnes others:





    https://www.phing.info/docs/guide/trunk/

    View Slide

  13. @phpdublin
    Adhoc Tasks
    class CreateusersTask extends Task {
    private $filename;
    function setFile($filename) {
    $this->filename = $filename;
    }
    function main() {
    $this->log("Createusers: " . $this->filename);
    $serialised = file_get_contents($this->filename);
    $users = unserialize($serialised);
    foreach($users as $userRow) {
    // Do something useful...
    $this->log(implode($output));
    }
    }
    }
    ]]>



    View Slide

  14. @phpdublin
    Custom Tasks
    Different to AdHoc in that they reside outside of XML file.


    tasks/inifile/IniFileSet.php
    tasks/inifile/IniFileTask.php
    tasks/inifile/IniFileConfig.php
    tasks/inifile/IniFileRemove.php
    tasks/NotifySendTask.php







    View Slide

  15. @phpdublin
    Questions?
    https://joind.in/14690

    View Slide