webCOMAND

Package Routing

Packages that contain files in the file system should organize their files using the following structure and naming conventions.  webCOMAND will recognize this organization to automatically route API, web and CLI requests.

The following files and folder will be recognized in a package folder.

  • index.php - Processed and served like standard PHP is served by the web server for the base package URL (ie. https://<account>.webcomand.com/package_namespace/).
  • cli/ - PHP files that can be run from the command-line interface (CLI).
  • config/ - Configuration files that can be easily accessed and loaded by the COMAND loader.
  • models/ - PHP content type models typically associated content types in the package.
  • public/ - PHP, HTML, CSS, JavaScript, images, fonts and other files that will be served like files in a typical "public_html" or "htdocs" folder.
  • libs/ - Folder for third-party PHP libraries used within the package.

Other files and folders will not be automatically recognized by the built-in COMAND router.  They can be organized however it makes sense.

Custom Routes

In addition to automatic routing described above, custom hostnames and package namespace can be configured with Route Settings.

Route Settings

One or more Route Settings can be created to configured custom routes.  Route Settings are typically added under the System folder to keep them all in one place, but it is not required.

Route Settings can configure three types of routes:

  • Global Aliases - Short aliases for package namespaces used for CLI and web routing.
  • CLI Aliases - Short aliases for package namespaces only used for CLI routing.
  • Web Routes - Hostnames and short aliases that can only used for web routing.

Route Settings

For step-by-step instructions to create custom routes, see the Routing Tutorial