Skip to content

Latest commit

 

History

History
34 lines (29 loc) · 2.03 KB

console-workflow.md

File metadata and controls

34 lines (29 loc) · 2.03 KB

Console Application Workflow

Table of Contents

  1. Introduction
  2. Workflow

Introduction

Apex uses a single point of entry for console applications. When typing php apex into the console, the apex bash file is executed, which instantiates the application and handles the request. Here's a breakdown of the workflow of a typical Apex console application:

Workflow

  1. User types php apex foo bar --baz=blah
  2. apex bash script loads bootstrap/console/start.php, which instantiates an Application object
  3. Various configs are read, and bootstrappers are registered
  4. Pre-start tasks are run
  5. Bootstrappers' bindings are registered by the bootstrapper Dispatcher
  6. Bootstrappers are run by the bootstrapper Dispatcher
  7. The application is started
  8. A console Kernel is instantiated with a request parser, the raw string input, and the response to write output to
  9. The Kernel uses the request parser to parse the input into a Request object
  • This contains the command name ("foo") and any arguments ("bar") and options ("--baz=blah")
  1. The command class whose name property matches the input command name is instantiated
  2. A command compiler compiles the command with the Request
  3. The command is executed
  4. A response compiler compiles any output produced by the command
  • A lexer lexes the raw response into a stream of tokens
  • A parser converts the tokens into an abstract syntax tree
  • The compiler compiles the abstract syntax tree into ANSI codes used to style the output
  1. Output is written to the kernel's Response, and the command's status code is returned
  2. Post-start tasks are run
  3. Pre-shutdown tasks are run
  4. The application is shut down
  5. Post-shutdown tasks are run