Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 08a78d4

Browse files
committed
Merge pull request #45 from froschdesign/hotfix/docs
Updates for documentation
2 parents ee4fa5b + 309d5e8 commit 08a78d4

File tree

14 files changed

+54
-62
lines changed

14 files changed

+54
-62
lines changed

docs/book/adapter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Console adapters
1+
# Console Adapters
22

33
zend-console's console abstraction layer works around various bugs and limitations
44
in operating systems, including:

docs/book/getopt/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Configuring Zend\\Console\\Getopt
1+
# Configuration
22

33
## Adding Option Rules
44

docs/book/getopt/fetching.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Alternatively, you can use the property overloading via the magic `__isset()` an
6060
`__get()` methods, allowing you to test for and retrieve values as if they were
6161
property names.
6262

63-
### Using property overloading
63+
### Using property Overloading
6464

6565
```php
6666
$opts = new Zend\Console\Getopt('abp:');
@@ -70,7 +70,7 @@ if (isset($opts->b)) {
7070
$p_parameter = $opts->p; // null if not set
7171
```
7272

73-
> ### Using aliases
73+
> ### Using Aliases
7474
>
7575
> If your options are declared with aliases, you may use any of the aliases for
7676
> an option when retrieving its value.

docs/book/getopt/intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Zend\\Console\\Getopt
1+
# Introduction
22

33
The `Zend\Console\Getopt` class helps command-line applications to parse their
44
options and arguments.

docs/book/getopt/rules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Declaring Getopt Rules
1+
# Declaring Rules
22

33
The constructor for the `Zend\Console\Getopt` class takes from one to three
44
arguments. The first argument declares which options are supported by your

docs/book/index.html

Lines changed: 0 additions & 10 deletions
This file was deleted.

docs/book/index.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/book/index.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
> ### Deprecated!
2+
>
3+
> Both the zend-console and the [zend-mvc-console](https://docs.zendframework.com/zend-mvc-console/)
4+
> components will likely not be maintained long-term, as there are more complete
5+
> implementations available elsewhere. We strongly urge developers to start
6+
> migrating their console tooling to use other libraries, such as
7+
> [symfony/console](https://github.com/symfony/console).
8+
9+
## Installation
10+
11+
```bash
12+
$ composer require zendframework/zend-console
13+
```

docs/book/intro.md

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
# Introduction to zend-console
2-
3-
> ### Deprecated
4-
>
5-
> Both the zend-console and the [zend-mvc-console](https://docs.zendframework.com/zend-mvc-console/)
6-
> components will likely not be maintained long-term, as there are more complete
7-
> implementations available elsewhere. We strongly urge developers to start
8-
> migrating their console tooling to use other libraries, such as
9-
> [symfony/console](https://github.com/symfony/console).
1+
# Introduction
102

113
zend-console provides both generic support for routable console applications, as
124
well as the basis for adding console support to zend-mvc-based applications.
@@ -71,7 +63,7 @@ the action `resetpassword` of `Application\Controller\IndexController`.
7163
7264
First we need to create a **route definition**:
7365

74-
```
66+
```text
7567
user resetpassword <userEmail>
7668
```
7769

@@ -80,15 +72,15 @@ This simple route definition expects exactly three arguments: the literal
8072
"userEmail". Let's assume we also accept one optional parameter to enable
8173
verbose operation:
8274

83-
```
75+
```text
8476
user resetpassword [--verbose|-v] <userEmail>
8577
```
8678

8779
The modified console route above expects the same three arguments from our
8880
original example, but will also recognise an optional `--verbose` flag, or its
8981
shorthand version, `-v`.
9082

91-
> ### Flag order
83+
> ### Flag Order
9284
>
9385
> The order of flags is ignored by zend-console. Flags can appear before
9486
> positional parameters, after them, or anywhere in between. The order of
@@ -147,7 +139,7 @@ return [
147139
;
148140
```
149141

150-
## Handling console requests
142+
## Handling Console Requests
151143

152144
When a user runs our application from the command line and arguments match our
153145
console route, the specified controller will be instantiated, and the specified
@@ -157,7 +149,6 @@ As such, let's add the `resetpassword` action to our
157149
`Application\Controller\IndexController`:
158150

159151
```php
160-
<?php
161152
namespace Application\Controller;
162153

163154
use RuntimeException;
@@ -214,7 +205,7 @@ The above creates `resetpasswordAction()`, which:
214205
- performs work based on the arguments;
215206
- and finally returns a simple string to display to the user via the console.
216207

217-
## Adding console usage info
208+
## Adding Console Usage Info
218209

219210
Console applications commonly display usage information when run without
220211
arguments. The combination of zend-console and zend-mvc enables this out of the
@@ -224,8 +215,6 @@ modules for console usage information they expose.
224215
Let's modify our `Application\Module` to provide usage info:
225216

226217
```php
227-
<?php
228-
229218
namespace Application;
230219

231220
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;

docs/book/mvc/controllers.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Console-aware controllers
1+
# Console-Aware Controllers
22

33
When using the zend-mvc integration with zend-console, a matched route results
44
in dispatch of an action controller. In this chapter we will learn how ZF2
55
Controllers can interact with and return output to console window.
66

7-
## Handling console requests
7+
## Handling Console Requests
88

99
Console requests are very similar to HTTP requests. In fact, they implement a
1010
common interface and are created at the same time in the MVC workflow. [Console
@@ -102,7 +102,7 @@ We fetch the console request, read parameters, and load users from our
102102
(theoretical) users service. In order to make this method functional, we'll
103103
have to display the result in the console window.
104104

105-
## Sending output to the console
105+
## Sending Output to the Console
106106

107107
The simplest way for our controller to display data in the console window is to
108108
return a string. Let's modify our example to output a list of users:
@@ -155,7 +155,7 @@ application.
155155
If any users are found, we loop through each to prepare a listing, which we then
156156
return from the action for display in the console.
157157

158-
## Are we in a console?
158+
## Are we in a Console?
159159

160160
Sometimes we might need to check if our method is being called from a console or
161161
from a web request. This is useful to block certain methods from running in the
@@ -188,7 +188,7 @@ class IndexController extends AbstractActionController
188188
}
189189
```
190190

191-
> ### Use routing to protect methods
191+
> ### Use Routing to protect Methods
192192
>
193193
> You do not need to secure all your controllers and methods from console
194194
> requests. Controller actions will **only be invoked** when at least one
@@ -243,13 +243,13 @@ class IndexController extends AbstractActionController
243243
> adapter, allowing you to use prompts, send output (including colorized output),
244244
> and more.
245245
246-
## Reading values from console parameters
246+
## Reading Values from Console Parameters
247247

248248
There are several types of parameters recognized by the Console component, all
249249
of which are described in the [console routing chapter](../routes.md). Here, we'll
250250
focus on how to retrieve values from distinct parameters and flags.
251251

252-
### Positional parameters
252+
### Positional Parameters
253253

254254
After a route matches, we can access both **literal parameters** and **value
255255
parameters** via the `$request` instance, using the `getParam()` method.

docs/book/mvc/modules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Console-aware modules
1+
# Console-Aware Modules
22

33
zend-mvc integrates with zend-console; the integration also works with modules
44
loaded with the

docs/book/mvc/routing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,21 @@ expects two parameters: `foo` and `bar`. If user puts these in a console,
5454
`Application\Controller\IndexController::passwordAction()` action will be
5555
invoked.
5656

57-
## Route types
57+
## Route Types
5858

5959
In the last example of the previous section, we noted that configuration for a
6060
given route can accept a `type` argument. This refers to the route type (which
6161
maps to a class) to use when creating the route instance. zend-mvc defines
6262
several types.
6363

64-
### Simple route
64+
### Simple Route
6565

6666
`Zend\Mvc\Router\Console\Simple` is a factory for zend-console's
6767
`DefaultRouteMatcher`, and decorates it to work with the zend-mvc routing
6868
system. See the section on [the default route matcher](../routes.md#the-default-route-matcher)
6969
for details on route strings and available configuration to provide.
7070

71-
### Catchall route
71+
### Catchall Route
7272

7373
This special route will catch all console requests, regardless of the parameters provided.
7474

docs/book/prompts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Console prompts
1+
# Console Prompts
22

33
In addition to the console abstraction layer, zend-console provides numerous
44
convenience classes for interacting with the user in a console environment. This

docs/book/routes.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Console routes and routing
1+
# Routes
22

33
A powerful feature the zend-console component exposes is *routing*. Routing
44
reads the command line arguments and matches them to criteria; if the criteria
55
matches, it then returns a list of matched parameters and flags.
66

7-
> ## Handling routing results
7+
> ### Handling routing results
88
>
99
> zend-console exposes routing via the `Zend\Console\RouteMatcher\DefaultRouteMatcher`
1010
> class, allowing you to create standalone routable console applications.
@@ -42,7 +42,7 @@ the routing implementation as an array; the routing implementation will then
4242
return either a `null` value (meaning failure to match), or an associative array
4343
(the values matched).
4444

45-
## The default route matcher
45+
## The default Route Matcher
4646

4747
zend-console's default routing implementation is `Zend\Console\RouteMatcher\DefaultRouteMatcher`.
4848
Its constructor expects:
@@ -89,13 +89,13 @@ The arguments are as follows:
8989
validators are used to validate values, and provide more options than simply
9090
regular expressions (as used with the `$constraints`).
9191

92-
> ### Single routes only
92+
> ### Single Routes only
9393
>
9494
> `DefaultRouteMatcher` instances define *a single console route to match*. Most
9595
> times, you will want to define multiple routes. The zend-mvc integration and
9696
> zf-console both provide methods for aggregating routes.
9797
98-
## Routing strings
98+
## Routing Strings
9999

100100
Routing strings consist of one or more of the following:
101101

@@ -106,7 +106,7 @@ Routing strings consist of one or more of the following:
106106
- [Named literal alternative groups](#grouping-literal-alternatives) (e.g., `(all|some|none):filter`)
107107
- [Catch-all parameters](#catch-all-parameters) (e.g. `[...params]`)
108108

109-
### Literal parameters
109+
### Literal Parameters
110110

111111
*Literal parameters* are expected to appear on the command line exactly the way
112112
they are provided in the route. For example:
@@ -168,7 +168,7 @@ $ zf show admin users
168168
>
169169
> As such, you can use whitespace for readability.
170170
171-
### Literal flags
171+
### Literal Flags
172172
173173
Console tools commonly use flags. zend-console allows you to define any number
174174
of optional and/or mandatory flags.
@@ -224,7 +224,7 @@ $ zf check users -t -f -v
224224
# etc.
225225
```
226226

227-
### Positional value parameters
227+
### Positional Value Parameters
228228

229229
Value parameters capture any text-based input, and come in two forms: positional
230230
and flags (which we've already discussed).
@@ -282,7 +282,7 @@ This allows us to capture commands such as the following:
282282
$ zf create user Johnny Bravo john@acme.org Entertainer
283283
```
284284

285-
> #### Escaping
285+
> ### Escaping
286286
>
287287
> Command line arguments on all systems must be properly escaped; otherwise they
288288
> will not be passed to our application correctly. For example, to create a user
@@ -293,7 +293,7 @@ $ zf create user Johnny Bravo john@acme.org Entertainer
293293
> $ zf create user "Johnan Tom" Bravo john@acme.org "Head of the Entertainment Department"
294294
> ```
295295
296-
### Value flag parameters
296+
### Value Flag Parameters
297297
298298
Positional value parameters are only matched if they appear in the exact order described in the
299299
route. If we do not want to enforce the order of parameters, we can define **value flags**.
@@ -320,7 +320,7 @@ $ zf find user --position "Head of the Entertainment Department"
320320
321321
As noted, the order of flags is irrelevant for the parser.
322322
323-
> ##### Providing values
323+
> ### Providing Values
324324
>
325325
> The parser understands values that are provided after either an equals symbol
326326
> (`=`) or a single space, but only if the value itself does not contain
@@ -345,7 +345,7 @@ $ zf rename user --id=123 --lastName=Bravo
345345
# etc.
346346
```
347347
348-
### Grouping literal alternatives
348+
### Grouping Literal Alternatives
349349
350350
In the flags section, we demonstrated grouping alternative flags:
351351
@@ -419,7 +419,7 @@ If the user entered the command line `say loudly I am here`, the 'volume'
419419
parameter would contain `'loudly'` and the 'words' parameter would contain
420420
`['I', 'am', 'here']`.
421421
422-
## Console routes cheat-sheet
422+
## Console Routes Cheat-Sheet
423423
424424
Param type | Example route definition | Explanation
425425
:--- | :--- | :---

mkdocs.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
docs_dir: docs/book
22
site_dir: docs/html
3-
pages:
3+
nav:
44
- Home: index.md
55
- Introduction: intro.md
66
- Reference:
@@ -17,6 +17,7 @@ pages:
1717
- 'Fetching Options and Arguments': getopt/fetching.md
1818
- Configuration: getopt/configuration.md
1919
site_name: zend-console
20-
site_description: Zend\Console
20+
site_description: 'Build console applications using getopt syntax or routing, complete with prompts'
2121
repo_url: 'https://github.com/zendframework/zend-console'
22-
copyright: 'Copyright (c) 2005-2019 <a href="http://www.zend.com/">Zend Technologies USA Inc.</a>'
22+
extra:
23+
show_special_homepage: true

0 commit comments

Comments
 (0)