Phing Cookbook
Free!
With Membership
$7.99
Minimum paid price

Phing Cookbook

The PHP Build Tool

About the Book

A new chapter is going to be published every month until the book is finished.

About the Author

Jawira Portugal
Jawira Portugal

Jawira Portugal is a software engineer, writer, and open source enthusiast. He has more than 10 years of experience in PHP development.

Table of Contents

  • Table of Contents
  • Recipes. 1
  • 1. First steps . . 3
  • 1.1. Introduction3
  • What is Phing? . . . 3
  • Advantages . . 4
  • Disadvantages . . . 4
  • 1.2. Installing Phing. 4
  • Install Phing as phar file . . 4
  • Installing Phing with Composer . . . 5
  • Installing Phing with Phive5
  • Getting auto-complete 6
  • Resources . . . 6
  • 1.3. Creating a buildfile . 6
  • Create an empty buildfile . 6
  • Buildfile structure 7
  • Init option . . . 7
  • Resources . . . 7
  • 1.4. Displaying text messages 8
  • EchoTask 8
  • Displaying long messages . 8
  • Escaping special characters . . . 9
  • Sending desktop notifications 10
  • Resources . . 11
  • 1.5. List available targets . . . 11
  • List targets in terminal . . 11
  • Visualize targets 12
  • Resources . . 13
  • 1.6. Imposing a minimum Phing version . 13
  • Use phingVersion attribute. . . 13
  • Alternative solutions 14
  • Using pre-releases. . . 14
  • Resources . . 15
  • 2. Working with properties . . . 17
  • 2.1. Loading properties from a file . . 17
  • Using -propertyfile option17
  • Loading property files with PropertyTask . 18
  • Loading properties from yaml file 19
  • Loading properties from xml file . 19Resources . . 20
  • 2.2. Persisting properties . . . 20
  • Using EchoPropertiesTask . . . 20
  • Advanced filtering rules . 21
  • Export all properties 21
  • Resources . . 22
  • 3. Basic usage . . . 23
  • 3.1. Checking if a string is empty 23
  • isfalse condition 23
  • Resources . . 25
  • 3.2. Get current date and time . . 25
  • Built-in phing.startTime property. 25
  • Use a specific date. . . 27
  • Use custom format and locale 27
  • Resources . . 29
  • 4. Filesystem 31
  • 4.1. Create a file . . . 31
  • Creating an empty file . . . 31
  • Empty an existing file . . . 31
  • Creating big files 32
  • Resources . . 32
  • 4.2. Copy files and directories. . . 32
  • Copy a file . . 32
  • Copy a directory 34
  • Copy multiple files . . 34
  • Resources . . 35
  • 5. Networking . . . 37
  • 5.1. Using HttpGetTask, HttpRequestTask , and VisualizerTask behind a proxy server 37
  • phing.http.proxy property . . . 37
  • Configure proxy server settings for a single task . . . 37
  • Resources . . 37
  • 6. Building your project . . 39
  • 6.1. Generate a checksum for a file . . 39
  • File checksum with FileHashTask. 39
  • Generate a manifest file . 40
  • Resources . . 40
  • 6.2. Install Composer dependencies . 40
  • Using ComposerTask 41
  • Using other Composer commands 41
  • Resources . . 42
  • 6.3. Replace text using placeholders . 42Using ReplaceTokenFilter 42
  • Customize delimiters 43
  • Resources . . 43
  • 7. Quality assurance . 45
  • 7.1. Validate Composer . 45
  • Validation using ComposerTask . . 45
  • Check outdated packages 45
  • Resources . . 45
  • 7.2. Check PHP syntax. . 46
  • Syntax checking with PhpLintTask46
  • Errors report . . . 47
  • Test syntax with specific PHP version . 47
  • Check deprecated syntax 48
  • Resources . . 49

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub