Waffle Recipes

How-To's and Tutorials for the ActiveWAFL Framework

How to Generate a .phar File

Posted Mar 3, 2015

There are a few of ways to generate .phar PHP archives with ActiveWAFL. We'll cover all of them here.

Interactive Command-Line

If you are generating a phar by hand, then this is probably the easiest way to do it. Use the Utensils command-line application to generate the phar.

  • Open a command prompt / terminal and cd to /usr/share/Wafl/Bin
  • Run the Utensils application by typing:
    • Linux: ./Utensils
    • Window: Utensils
  • In the Main Menu, choose option p
  • Folder path: Enter the absolute path to the folder that contains the files to be added to the phar. The folder itself will not be added, but all of it's contents will.
  • App/Module Name: Enter the name that you want to give to the phar file
  • Entry point file: The file that will be automatically executed whenever the phar is invoked
  • Destination folder: The folder where the new phar file willbe saved
  • Utensils will output a list of files that are added to the phar

,-.  .   .                .
  |  |   |- ,-. ,-. ,-. . |  ,-.
  |  | . |  |-' | | `-. | |  `-.
  `--^-' `' `-' ' ' `-' ' `' `-'
for ActiveWAFL 0.4.2046

    a. Generate a new (a)application
    c. Generate a new (c)ontrol
    e. Generate a new (e)xtension
    h. (H)elp
    i. Show system (i)nformation
    p. Make a (p)har
    u. (U)pdate ActiveWafl
    x. E(x)it

Please choose a letter from the menu: p
What is the path to the folder you want to pharchive?
Folder path: /path/to/source/folder/
What is the app/module name you want to give to this pharchive?
App/Module Name: MyPharchive
What entry point file do you want to use for the phar?
Entry point file (leave blank for null): Bootstrap.php
Where do you want to save the generated file?
Destination folder (leave blank for current folder): /output/folder
 

Automated Command-Line, Full Directory

If you want to generate the phar from a single source directory in a single one-line command, or if you want to automate phar generation, then this is a good way to do it.

  • Open a command prompt / terminal and cd to /usr/share/Wafl/Bin
  • Run the Utensils application by typing:
    • Linux: ./Utensils -p "/path/to/source/folder/" "MyPharchive" null "/output/folder/"
    • Window: Utensils -p "c:/path/to/source/folder/" "MyPharchive" null "c:/output/folder/"
  • Or, if you want to specify an entry point file to be run automatically:
    • Linux: ./Utensils -p "/path/to/source/folder/" "MyPharchive" EntryFile.php "/output/folder/"
    • Window: Utensils -p "c:/path/to/source/folder/" "MyPharchive" EntryFile.php "c:/output/folder/"

Automated Command-Line, Directory and Individual Files

This is another easy way to generate the phar in a single one-line command, except with this method you can specify additional files individually.

GeneratePhar Signature

GeneratePhar APPNAME SOURCEFOLDER DESTINATIONFOLDER [COMPRESS] [ENTRYPOINTFILENAME] [ADD_EXTERNAL_FILE] [ADD_EXTERNAL_FILE]...
  • Open a command prompt / terminal and cd to /usr/share/Wafl/Bin
  • Run the GeneratePhar application by typing:
    • Linux: ./GeneratePhar "MyPharchive" "/path/to/source/folder/" "/output/folder/" 1 null "/path/to/extrafile.php" "/path/to/extrafile2.php"
    • Window: GeneratePhar "MyPharchive" "c:/path/to/source/folder/" "c:/output/folder/" 1 null "c:/path/to/extrafile.php" "c:/path/to/extrafile2.php"