Skip to content

Repository files navigation

Phapp CLI

Provides standardized console commands for PHP applications.

Requirements

  • Git version >= 2.0
  • Bash 4.*
  • PHP >5.6|>7.0

Installation

Installation requires composer. As there are some dependency conflicts with the latest drush release it is recommended to install the tool via consolidation/cgr. To do so, just execute:

# Download latest stable release.
php -r "
ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 6.0)');
readfile(json_decode(file_get_contents('https://api.github.com/repos/drunomics/phapp-cli/releases/latest'))->assets[0]->browser_download_url);
" > phapp
chmod +x phapp
# Optional: Ensure ~/bin exists and configure it to be available in $PATH.
[ -d ~/bin ] || mkdir ~/bin
echo $PATH | grep -q ~/bin || (echo "export PATH=~/bin:\$PATH" >> ~/.bashrc && export PATH=~/bin:$PATH)
# Make phapp executable from everywhere by moving to a destination available in $PATH.
# If you skipped the optional step above, be sure to move it to a suiting destination.
mv phapp ~/bin/phapp

Updating

Run

 phapp self:update

Usage

Run phapp list to show a list of support commands and use phapp command --help for more information about a command. The list of currently available commands is:

 build Builds the project with the current code checkout.
clone Clones a Phapp project.
create Creates a new project base on a given template.
help Displays help for a command
init Initializes the app.
install Installs the application.
list Lists commands
setup Setups the phapp environment.
status Checks for a working and installed application.
update Updates the app.
build
build:branch Builds a given branch.
build:clean Cleans all build related files.
git
git:pull Updates local branches by pull from remote repositories.
git:setup-remotes Configures Git remote repositories.
init
init:manifest Initializes a new phapp.yml for your project.
self
self:update Updates the installed phar.

phapp.yml

An application provides basic metadata and customizes commands in its phapp.yml, the phapp manifest. See examples/phapp.yml for an example.

Phapp environment variables

Commands defined in phapp.yml may make use of the phapp environment variables.

Dotenv support

Phapp environment variables are either set by the environment; i.e. the host, or via a .env file.

In order to help with initializing the environment based upon one or multiple .env files the environment command may be used. This command is prepended the other commands (except setup) such that they may rely on the initialized environment.

Thus, the .env file can be written as part of the setup command and sourced as part of the environment command.

Available variables

Available environment variables are / must be:

VariableDescriptionExample value
PHAPP_ENVThe environment name. E.g., local, test or livelive
PHAPP_ENV_TYPEThe environment type; e.g. an id for the hosting environment or type of server.acquia
PHAPP_ENV_MODEThe environment mode; valid values are: production, developmentproduction
PHAPP_BASE_URLThe base URL of the app.https://example.com

Optional environment variables are:

VariableDescriptionExample value
PHAPP_ENV_COLORA color used for indicating the current environment.302f2f

Database connection.

PHAPP_ENV_MYSQL_DEFAULT_DATABASE=database
PHAPP_ENV_MYSQL_DEFAULT_USERNAME=user
PHAPP_ENV_MYSQL_DEFAULT_PASSWORD=pass
PHAPP_ENV_MYSQL_DEFAULT_HOST=localhost
PHAPP_ENV_MYSQL_DEFAULT_PORT="3306"

Various other variables provided by the environment.

PHAPP_ENV_DUMP_DIR="/data/mysql_dumps/sync"
PHAPP_ENV_DUMP_DB_FILENAME="${PHAPP_ENV_MYSQL_DEFAULT_DATABASE}-$(date -d "1 day ago" +%Y%m%d).sql.gz"

Phapp development

Build a new phar

The phar is built using box, for details see https://github.com/box-project/box. To built the phar just run:

 composer install --dev
composer build

Create a new release

  • Tag a new version and push it.
  • Build a new phar (see above).
  • Upload the new phar at the github release page. Keep the filename as is.
  • Note that the packagist API is not updated immediately. Thus it takes a few minutes until the new release is picked up by the self:update command.

About

Standardized console commands for managing PHP applications.

Topics

Resources

Stars

7 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages