55dee4d287fce54cdd47919e700719dcc28a6faa
[yaffs-website] / vendor / consolidation / site-alias / README.md
1 # SiteAlias
2
3 Manage alias records for local and remote sites.
4
5 [![Travis CI](https://travis-ci.org/consolidation/site-alias.svg?branch=master)](https://travis-ci.org/consolidation/site-alias)
6 [![Windows CI](https://ci.appveyor.com/api/projects/status/6mp1hxmql85aw7ah?svg=true)](https://ci.appveyor.com/project/greg-1-anderson/site-alias)
7 [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/consolidation/site-alias/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/consolidation/site-alias/?branch=master)
8 [![Coverage Status](https://coveralls.io/repos/github/consolidation/site-alias/badge.svg?branch=master)](https://coveralls.io/github/consolidation/site-alias?branch=master) 
9 [![License](https://img.shields.io/badge/license-MIT-408677.svg)](LICENSE)
10
11 ## Overview
12
13 This project provides the implementation for Drush site aliases. It is used in Drush 9 and later. It would also be possible to use this library to manage site aliases for similar commandline tools.
14
15 ### Alias naming conventions
16
17 Site alias names always begin with a `@`, and typically are divided in three parts: the alias file location (optional), the site name, and the environment name, each separated by a dot. None of these names may contain a dot. An example alias that referenced the `dev` environment of the site `example` in the `myisp` directory might therefore look something like:
18 ```
19 @myisp.example.dev
20 ``` 
21 The location name is optional. If specified, it will only consider alias files located in directories with the same name as the provided location name. The remainder of the path is immaterial; only the directory that is the immediate parent of the site alias file is relevant. The location name may be omitted, e.g.:
22 ```
23 @example.dev
24 ```
25 If the location is not specified, then the alias manaager will consider all locations for an applicable site alias file. Note that by default, deep searching is disabled; unless deep searching is enabled, the location name must refer to a directory that is explicitly listed as a location to place site alias files (e.g. in the application's configuration file).
26
27 It is also possible to use single-word aliases. These can sometimes be ambiguous; the site alias manager will resolve single-word aliases as follows:
28
29 1. `@self` is interpreted to mean the site that has already been selected, or the site that would be selected in the absence of any alias.
30 2. `@none` is interpreted as the empty alias--an alias with no items defined.
31 3. `@<env>`, for any `<env>` is equivalent to `@self.<env>` if such an alias is defined. See below.
32 4. `@<site>`, for any `<site>` is equivalent to the default environment of `<site>`, e.g. `@<site>.<default>`. The default environment defaults to `dev`, but may be explicitly set in the alias.
33
34 ### Alias placement on commandline
35
36 It is up to each individual commandline tools how to utilize aliases. There are two primary examples:
37
38 1. Site selection alias: `tool @sitealias command`
39 2. Alias parameters: `tool command @source @destination`
40
41 In the first example, with the site alias appearing before the command name, the alias is used to determine the target site for the current command. In the second example, the arguments of the command are used to specify source and destination sites.
42
43 ### Alias filenames and locations
44
45 It is also up to each individual commandline tool where to search for alias files. Search locations may be added to the SiteAliasManager via an API call. By default, alias files are only found if they appear immediately inside one of the specified search locations. Deep searching is only done if explicitly enabled by the application.
46
47 Aliases are typically stored in Yaml files, although other formats may also be used if a custom alias data file loader is provided. The extension of the file determines the loader type (.yml for Yaml). The base name of the file, sans its extension, is the site name used to address the alias on the commandline. Site names may not contain periods.
48
49 ### Alias file contents
50
51 The canonical site alias will contain information about how to locate the site on the local file system, and how the site is addressed on the network (when accessed via a web browser).
52 ```
53 dev:
54   root: /path/to/site
55   uri: https://example.com
56 ```
57 A more complex alias might also contain information about the server that the site is running on (when accessed via ssh for deployment and maintenance).
58 ```
59 dev:
60   root: /path/to/site
61   uri: https://example.com
62   remote: server.com
63   user: www-data
64 ```
65
66 ### Wildcard environments (Experimental)
67
68 It is also possible to define "wildcard" environments that will match any provided environment name. This is only possible to do in instances where the contents of the wildcard aliases are all the same, except for places where the environment name appears. To substitute the name of the environment into a wildcard domain, use the variable replacement string `${env-name}`. For example, a wildcard alias that will match any multisite in a Drupal site might look something like the following example:
69 ```
70 '*':
71   root: /wild/path/to/wild
72   uri: https://${env-name}.example.com
73 ```
74
75 ### 'Self' environment aliases
76
77 As previously mentioned, an alias in the form of `@<env>` is interpreted as `@self.<env>`. This allows sites to define a `self.site.yml` file that contains common aliases shared among a team--for example, `@stage` and `@live`.
78
79 ## Site specifications
80
81 Site specifications are specially-crafted commandline arguments that can serve as replacements for simple site aliases. Site specifications are particularly useful for scripts that may wish to operate on a remote site without generating a temporary alias file.
82
83 The basic form for a site specification is:
84 ```
85 user.name@example.com/path#uri
86 ```
87 This is equivalent to the following alias record:
88 ```
89 env:
90   user: user.name
91   host: example.com
92   root: /path
93   uri: somemultisite
94 ```
95
96 ## Getting Started
97
98 To get started contributing to this project, simply clone it locally and then run `composer install`.
99
100 ### Running the tests
101
102 The test suite may be run locally by way of some simple composer scripts:
103
104 | Test             | Command
105 | ---------------- | ---
106 | Run all tests    | `composer test`
107 | PHPUnit tests    | `composer unit`
108 | PHP linter       | `composer lint`
109 | Code style       | `composer cs`     
110 | Fix style errors | `composer cbf`
111
112 ### Development Commandline Tool
113
114 This library comes with a commandline tool called `alias-tool`. The only purpose
115 this tool serves is to provide a way to do ad-hoc experimentation and testing
116 for this library.
117
118 Example:
119 ```
120 $ ./alias-tool site:list tests/fixtures/sitealiases/sites/
121
122  ! [NOTE] Add search location: tests/fixtures/sitealiases/sites/                                    
123
124 '@single.alternate':
125   foo: bar
126   root: /alternate/path/to/single
127 '@single.dev':
128   foo: bar
129   root: /path/to/single
130 '@wild.*':
131   foo: bar
132   root: /wild/path/to/wild
133   uri: 'https://*.example.com'
134 '@wild.dev':
135   foo: bar
136   root: /path/to/wild
137   uri: 'https://dev.example.com'
138
139 $ ./alias-tool site:get tests/fixtures/sitealiases/sites/ @single.dev
140
141  ! [NOTE] Add search location: tests/fixtures/sitealiases/sites/                                    
142
143  ! [NOTE] Alias parameter: '@single.dev'                                                            
144
145 foo: bar
146 root: /path/to/single
147 ```
148 See `./alias-tool help` and `./alias-tool list` for more information.
149
150 ## Release Procedure
151
152 To create a release:
153
154 - Edit the `VERSION` file to contain the version to release, and commit the change.
155 - Run `composer release`
156
157 ## Built With
158
159 This library was created with the [g1a/starter](https://github.com/g1a/starter) project, a fast way to create php libraries and [Robo](https://robo.li/) / [Symfony](https://symfony.com/) applications.
160
161 ## Contributing
162
163 Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on the process for submitting pull requests to us.
164
165 ## Versioning
166
167 We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [releases](https://github.com/consolidation/site-alias/releases) page.
168
169 ## Authors
170
171 * **Greg Anderson**
172 * **Moshe Weitzman**
173
174 See also the list of [contributors](https://github.com/consolidation/site-alias/contributors) who participated in this project. Thanks also to all of the [drush contributors](https://github.com/drush-ops/drush/contributors) who contributed directly or indirectly to site aliases.
175
176 ## License
177
178 This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details