# Understanding Cockpit - A development guide (work in progress...)

**URL:** https://discourse.getcockpit.com/t/understanding-cockpit-a-development-guide-work-in-progress/486
**Category:** General
**Created:** [January 2, 2019, 9:09pm UTC](https://discourse.getcockpit.com/t/understanding-cockpit-a-development-guide-work-in-progress/486 "2019-01-02T21:09:03Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)
#### Post date: [January 2, 2019, 9:21pm UTC](https://discourse.getcockpit.com/t/understanding-cockpit-a-development-guide-work-in-progress/486/2 "2019-01-02T21:21:02Z")

</div>

# Explanation of all paths and constants

A few weeks ago, I started to analyze all the paths and constants. For most of them I added a few lines of explanation. I will update this list with the missing parts when I find the time to do it.

The example paths are on an [Uberspace](https://manual.uberspace.de/) (CentOS 7) in `~/html/cockpit`.

* * *

Originally, I wrote this text in kramdown and rendered it to HTML. If you want to see the rendered file with a table of contents, have a look here:

- [source .md](https://github.com/raffaelj/cockpit-scripts/blob/master/development-notes/constants-and-paths.md), [source .html](https://github.com/raffaelj/cockpit-scripts/blob/master/development-notes/constants-and-paths.html)
- view via [htmlpreview.github.io](https://htmlpreview.github.io/?https://github.com/raffaelj/cockpit-scripts/blob/master/development-notes/constants-and-paths.html)

* * *

## type constants

If no type constant is set to `1`, cockpit was called as library.

### COCKPIT\_ADMIN

`[COCKPIT_ADMIN] => 1`

- called `index.php`
- triggered `admin.init`

### COCKPIT\_CLI

`[COCKPIT_CLI] =>`

called from cli `./cp ...`

### COCKPIT\_API\_REQUEST

`[COCKPIT_API_REQUEST] => 0`

- api request
- called via `domain.tld/path/to/cockpit/api/...`

## other constants

### COCKPIT\_START\_TIME

`[COCKPIT_START_TIME] => 1542646468.3189`

for debugging: duration time

### COCKPIT\_ADMIN\_ROUTE

`[COCKPIT_ADMIN_ROUTE] => /`

- current route, url part after `domain.tld/path/to/cockpit`
- e. g. `/collections`

## path constants

### COCKPIT\_BASE\_URL

`[COCKPIT_BASE_URL] => /cockpit`

- for `COCKPIT_ADMIN_ROUTE` detection
- sets registry: `base_url`

```auto
* What is the difference between `COCKPIT_BASE_URL` and `COCKPIT_BASE_ROUTE`?

```

### COCKPIT\_BASE\_ROUTE

`[COCKPIT_BASE_ROUTE] => /cockpit`

- sets registry: `base_route`

```auto
* What is the difference between `COCKPIT_BASE_URL` and `COCKPIT_BASE_ROUTE`?

```

### COCKPIT\_SITE\_DIR

`[COCKPIT_SITE_DIR] => /var/www/virtual/username`

- parent of root
- used for relative paths of assets
- used for relative path of config file in `/settings/edit`
- sets registry: `site`

### COCKPIT\_DOCS\_ROOT

`[COCKPIT_DOCS_ROOT] => /var/www/virtual/username/html`

- root
- used for relative paths of assets
- part of define `COCKPIT_SITE_DIR`
- sets registry: `docs_root`

### COCKPIT\_DIR

`[COCKPIT_DIR] => /var/www/virtual/username/html/cockpit`

```auto
to do

```

### COCKPIT\_CONFIG\_DIR

`[COCKPIT_CONFIG_DIR] => /var/www/virtual/username/html/cockpit/config`

- location of config dir
- sets paths: `#config`

### COCKPIT\_CONFIG\_PATH

`[COCKPIT_CONFIG_PATH] => /var/www/virtual/username/html/cockpit/config/config.yaml`

can be `COCKPIT_CONFIG_DIR/*.php` of `COCKPIT_CONFIG_DIR/*.yaml`

### COCKPIT\_STORAGE\_FOLDER

`[COCKPIT_STORAGE_FOLDER] => /var/www/virtual/username/html/cockpit/storage`

- sets paths: `#storage`
- sets paths: `#data`
- sets paths: `#cache`
- sets paths: `#tmp`
- also used in install script for writable check

### COCKPIT\_PUBLIC\_STORAGE\_FOLDER

`[COCKPIT_PUBLIC_STORAGE_FOLDER] => /var/www/virtual/username/html/cockpit/storage`

- sets paths: `#pstorage`
- sets paths: `#thumbs`
- sets paths: `#uploads`

## registry

### route

`[route] => /`

see [COCKPIT\_ADMIN\_ROUTE](#cockpit_admin_route)

### base\_url

`[base_url] => /cockpit`

```auto
to do

```

- used in
  - App
    - `baseUrl($path)`
      - calls: `pathToUrl($path)`
      - called from: `base($path)`

  - LimeExtra
    - `@base()`

### base\_route

`[base_route] => /cockpit`

- used in
  - App
    - `routeUrl($path)`
      - `route()`
      - `reroute($path)`

  - LimeExtra
    - `@route()`

### docs\_root

`[docs_root] => /var/www/virtual/username/html`

- used in
  - App
    - `pathToUrl($path, $full = false)`
      - `assets($src, $version=false)`
        - `style($href, $version=false)`
        - `script($href, $version=false)`

      - `baseUrl($path)`
        - `base($path)`

  - LimeExtra
    - `@base()`
    - `@assets()`
    - `@url()`
    - ``

### other

`[site_url] => https://username.uber.space`  
`[base_host] => username.uber.space`  
`[base_port] => 443`

…

## paths

```auto
to do...

```

`[#root] => /var/www/virtual/username/html/cockpit`  
`[#storage] => /var/www/virtual/username/html/cockpit/storage`  
`[#pstorage] => /var/www/virtual/username/html/cockpit/storage`  
`[#data] => /var/www/virtual/username/html/cockpit/storage/data`  
`[#cache] => /var/www/virtual/username/html/cockpit/storage/cache`  
`[#tmp] => /var/www/virtual/username/html/cockpit/storage/tmp`  
`[#thumbs] => /var/www/virtual/username/html/cockpit/storage/thumbs`  
`[#uploads] => /var/www/virtual/username/html/cockpit/storage/uploads`  
`[#modules] => /var/www/virtual/username/html/cockpit/modules`  
`[#addons] => /var/www/virtual/username/html/cockpit/addons`  
`[#config] => /var/www/virtual/username/html/cockpit/config`  
`[assets] => /var/www/virtual/username/html/cockpit/assets`  
`[site] => /var/www/virtual/username`

---

_[View the full topic](https://discourse.getcockpit.com/t/understanding-cockpit-a-development-guide-work-in-progress/486)._
