ActiveWAFL Crash Course

The WAFL Cones Ice Cream Shop, Version 1.0

2.1: Generate the Application

Overview

We'll use the ActiveWAFL Utensils utility to generate a starting point for Wafl Cones.

  1. Use Utensils to generate an .ini pre-configuration file
  2. Modify the values in the .ini file
  3. Create an application using the .ini pre-configuration file
  4. Setup web hosting

Run Utensils with interactive menus by executing Utensils with no additional arguments:

*nix

chmod +x Utensils
Utensils
 
Windows

chmod +x Utensils
Utensils.bat
 

You will be presented with a menu similar to the following.


,-.  .   .                .
  |  |   |- ,-. ,-. ,-. . |  ,-.
  |  | . |  |-' | | `-. | |  `-.
  `--^-' `' `-' ' ' `-' ' `' `-'
for ActiveWAFL 0.3.x

    a. Generate a new (a)application
    b. Submit a (b)ug report
    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:
 

To generate the application:

Press a,

You will be prompted for an action similar to the following.


Please choose a letter from the menu: a
Create a New Application...

You can generate a default application with dummy settings, or you can generate
a preconfigured stub using settings that you specify in an ini file.

P = Generate preconfigured application using an ini file that I supply. (use opt
ion "I" to generate an ini file that you can customize)
D = Use dummy settings.
I = Generate an ini stub that I can customize and use to create a preconfigured
application.

Which would you like to do? (P/D/I)
 

Setup the pre-configuration for Wafl Cones

Choose option I.  You will be prompted for the folder you want to save the .ini file in.

Type the /path/to/some/folder where you want to save the Settings.ini file and press .


Which would you like to do? (P/D/I)i
What directory would you like to save the ini file in?
c:/xampp/tmp/Settings.ini

C:\xampp\tmp\Settings.ini has been created.
 

Settings.ini

Edit the values in the Settings.ini file for the Wafl Cones application.

Settings.ini file with pre-configuration for Wafl Cones app on Windows.
Wafl and DblEj are installed at c:/xampp/vhosts/shared/Wafl and c:/xampp/vhosts/shared/DblEj, respectively.
  1. APPLICATION_NAME            =   Wafl Cones Ice Cream Shop
  2. APPLICATION_NAMESPACE       =   WaflCones
  3. APPLICATION_DOMAIN          =   waflcones.tld
  4. APPLICATION_GUID            =   WaflCones
  5. APPLICATION_TIMEZONE        =   America/Phoenix
  6. DEV_LOCAL_ROOT              =   c:/xampp/vhosts/d.waflcones.tld/
  7. DEV_TEMP_FOLDER             =   c:/xampp/tmp/WaflCones.dev/
  8. DEV_RELATIVE_WAFL_FOLDER    =   ../shared/Wafl/
  9. DEV_RELATIVE_DBLEJ_FOLDER   =   ../shared/DblEj/
  10. LOCAL_ROOT                  =   c:/xampp/vhosts/WaflCones.prod/
  11. TEMP_FOLDER                 =   c:/xampp/tmp/WaflCones.prod/
  12. RELATIVE_WAFL_FOLDER        =   ../shared/Wafl/
  13. RELATIVE_DBLEJ_FOLDER       =   ../shared/DblEj/
Settings.ini file with pre-configuration for Wafl Cones app on Linux.
Wafl and DblEj are installed at /var/www/Wafl and /var/www/DblEj, respectively.
  1. APPLICATION_NAME            =   Wafl Cones Ice Cream Shop
  2. APPLICATION_NAMESPACE       =   WaflCones
  3. APPLICATION_DOMAIN          =   waflcones.tld
  4. APPLICATION_GUID            =   WaflCones
  5. APPLICATION_TIMEZONE        =   America/Phoenix                    
  6. DEV_LOCAL_ROOT              =   /var/www/vhosts/d.waflcones.tld/
  7. DEV_TEMP_FOLDER             =   /tmp/WaflCones.dev/
  8. DEV_RELATIVE_WAFL_FOLDER    =   ../Wafl/                          
  9. DEV_RELATIVE_DBLEJ_FOLDER   =   ../DblEj/                          
  10. LOCAL_ROOT                  =   /var/www/vhosts/WaflCones.prod/
  11. TEMP_FOLDER                 =   /tmp/WaflCones.prod/
  12. RELATIVE_WAFL_FOLDER        =   ../../Wafl/                        
  13. RELATIVE_DBLEJ_FOLDER       =   ../../DblEj/
APPLICATION_NAME
Wafl Cones Ice Cream Shop
APPLICATION_NAMESPACE
WaflCones
APPLICATION_DOMAIN
waflcones.tld
APPLICATION_GUID
WaflCones
APPLICATION_TIMEZONE
a supported timezone e.g. America/Phoenix
DEV_LOCAL_ROOT
</local/webserver/folder[/vhosts]>/WaflCones.dev/
DEV_TEMP_FOLDER
</some/writable/temp/folder>/WaflCones.dev/
DEV_RELATIVE_WAFL_FOLDER
../Wafl/ (or wherever ActiveWAFL is installed, relative to DEV_LOCAL_ROOT)
DEV_RELATIVE_DBLEJ_FOLDER
../DblEj/ (or wherever DblEj is installed, relative to DEV_LOCAL_ROOT)

Create the application stub

Run Utensils again and generate a pre-configured application using our new Settings.ini file.


This is what it will look like in the console:


,-.  .   .                .
  |  |   |- ,-. ,-. ,-. . |  ,-.
  |  | . |  |-' | | `-. | |  `-.
  `--^-' `' `-' ' ' `-' ' `' `-'
for ActiveWAFL 0.3.x

    a. Generate a new (a)pplication
    b. Submit a (b)ug report
    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: a
Create a New Application...

You can generate a default application with dummy settings, or you can generate
a preconfigured stub using settings that you specify in an ini file.

P = Generate preconfigured application using an ini file that I supply. (use opt
ion "I" to generate an ini file that you can customize)
D = Use dummy settings.
I = Generate an ini stub that I can customize and use to create a preconfigured
application.

Which would you like to do? (P/D/I)p
What type of app are you making (App|WebApp|MvcWebApp|ModularMvcWebApp)?MvcWebAp
p
What is the path to the ini file?
c:/xampp/tmp/Settings.ini
What directory should I save the generated application in?
c:/xampp/vhosts/d.waflcones.tld
The new application has been created in C:\xampp\vhosts\WaflCones.dev.

C:\xampp\vhosts\shared\Wafl\Bin>_
 
Directory structure of the Wafl Cones demonstration application (shown in Netbeans 8)

Web Server Configuration

Since Wafl Cones will be a web app, you will need to set up web hosting.
In this example, you're shown how to setup the web site using virtual hosting on Apache 2.

The exact steps will differ if you are using a different web server, or if you are not using virtual hosting. However, the general concepts will still apply.

Setup a Virtual Host

  1. Add an entry to the server's virtual host config file (typically httpd.conf or httpd-vhosts.conf)
  2. Specify the environment type (dev|test|build|prod)
  3. Point the new domain name to your IP address
  4. Setup mod-rewrite to route all requests to index.php

Add a new VirtualHost directive to the server's virtual host configuration file

The new entry will look similar to the following.
  1. <VirtualHost *:80>
  2.     ServerAdmin admin@waflcones.tld
  3.     DocumentRoot "c:/xampp/vhosts/d.waflcones.tld/Public"
  4.     ServerName d.waflcones.tld
  5.     ServerAlias www.d.waflcones.tld
  6.     ErrorLog "C:/xampp/vhosts/d.waflcones.tld/Output/error.log"
  7.     CustomLog "C:/xampp/vhosts/d.waflcones.tld/Output/access.log" common
  8.    <Directory "C:/xampp/vhosts/d.waflcones.tld/Public">
  9.       AllowOverride All
  10.       Options All
  11.       Require all granted
  12.    </Directory>
  13. </VirtualHost>

Specify the environment

ActiveWAFL needs to know what environment the application is running as.
You must set an environment variable named WAFL_ENVIRONMENT to specify the current environment.

The default application stub will have an pre-configured .htaccess file that will set the environment as dev.

fragment taken from the default .htaccess file in an ActiveWAFL web application
  1. SetEnv WAFL_ENVIRONMENT dev

Point the domain to your ip address

Edit your hosts file to include an entry for the new domain by adding the following line.
127.0.0.1 d.waflcones.tld

The host file is usually located at
Windows: c:\windows\system32\drivers\etc\hosts
Linux: /etc/hosts

Note: You might also need to clear any DNS caches using flushdns or similar.

Route all requests to index.php

If you're using Apache and mod_rewrite, then this is already handled in Public/.htaccess.

fragment taken from the default .htaccess file in an ActiveWAFL web application showing mod-rewrite rules
  1. RewriteEngine On
  2. RewriteCond %{REQUEST_FILENAME} -s [OR]
  3. RewriteCond %{REQUEST_FILENAME} -l [OR]
  4. RewriteCond %{REQUEST_FILENAME} -d
  5. RewriteRule ^.*$ - [NC,L]
  6. RewriteRule ^.*$ index.php [NC,L]

Test out the installation

Open a new web browser and go to http://d.activewafl.tld.
If everything has gone well, you should see the default ActiveWAFl application home page, similar to the following.


Next: 2.2: Review the Application's Definition