├── .gitignore ├── Dockerfile ├── LICENSE.md ├── README.md ├── bin ├── pman └── sync-pman └── composer.json /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor/ 2 | /man3/ 3 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:stretch 2 | MAINTAINER William Durand 3 | 4 | RUN apt-get update && apt-get install --no-install-recommends -y php-pear man 5 | 6 | RUN pear install doc.php.net/pman 7 | RUN pear upgrade doc.php.net/pman 8 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 William Durand 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | pman 2 | ==== 3 | 4 | This package provides **pman**, the [PHP 5 | manual](http://fr.php.net/download-docs.php) in \*nix style man pages, via 6 | Composer and Packagist. 7 | 8 | 9 | Installation 10 | ------------ 11 | 12 | 1) This package SHOULD be installed **globally**: 13 | 14 | composer global require willdurand/pman:dev-master 15 | 16 | 2) Then, add `$COMPOSER_BIN_DIR` to your `$PATH`. 17 | 18 | `$COMPOSER_BIN_DIR` is often `~/.composer/vendor/bin`, but it may be different 19 | depending on your operating system or configuration. Also, it is important to 20 | use such a path and not directly, `.composer/vendor/bin`. 21 | 22 | 23 | Usage 24 | ----- 25 | 26 | 1) First, you have to fetch the documentation. This can be done time to time or 27 | only once, but it MUST be run at least once. 28 | 29 | sync-pman 30 | 31 | This script relies on [Docker](https://www.docker.com/). In case you want to 32 | clear Docker's cache, you can pass the `--no-cache` option to this script: 33 | 34 | sync-pman --no-cache 35 | 36 | 2) Run `pman` to display documentation (like you would do with `man`): 37 | 38 | pman strlen 39 | 40 | 41 | Why? 42 | ---- 43 | 44 | I stumbled upon [this 45 | article](http://dailyvim.blogspot.fr/2008/08/making-k-useful.html) (and a few 46 | others as well), explaining how to leverage `K` command in 47 | [`vim`](https://github.com/willdurand/vim-config). I decided to use this command 48 | rather than [my plain old way to display PHP manual 49 | entries](https://github.com/willdurand/vim-config/blob/40c39392afac3960aef6ac80320ddc172a0257c3/vim/ftplugin/php.vim#L1-L2). 50 | 51 | I don't use PEAR on my system, that is why I relied on Docker to fetch the PEAR 52 | package. Also, adding a script to fetch (and synchronize) the documentation 53 | rather than versioning all the files (as done 54 | [here](https://github.com/gonzaloserrano/pman-php-manual)) seemed better to me. 55 | 56 | 57 | License 58 | ------- 59 | 60 | (willdurand's) pman is released under the MIT License. See the bundled LICENSE 61 | file for details. Note that `pman`, the original package from PEAR, has its own 62 | license. 63 | -------------------------------------------------------------------------------- /bin/pman: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | MAN="$(which man)" 4 | SCRIPT_NAME="$(readlink -f "${BASH_SOURCE[0]}")" 5 | PHP_DIR="$(cd "$( dirname "${SCRIPT_NAME}" )/.." && pwd)" 6 | 7 | "$MAN" -M "$PHP_DIR" "$*" 8 | -------------------------------------------------------------------------------- /bin/sync-pman: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eo pipefail 4 | 5 | SCRIPT_NAME="$(readlink -f "${BASH_SOURCE[0]}")" 6 | ROOT_DIR="$(cd "$( dirname "${SCRIPT_NAME}" )/.." && pwd)" 7 | IMAGE_NAME="willdurand/pman" 8 | 9 | function usage() { 10 | declare script_name="$0" 11 | 12 | echo "$script_name [-h|--help] [--no-cache]" 13 | echo 14 | echo ' -h|--help : Display this help message' 15 | echo ' --no-cache : Rebuild Docker image with `--no-cache` flag' 16 | 17 | exit 1 18 | } 19 | 20 | function sync() { 21 | if [[ '--no-cache' == "$1" ]] ; then 22 | docker build --no-cache -t "$IMAGE_NAME" "$ROOT_DIR" 23 | else 24 | docker build -t "$IMAGE_NAME" "$ROOT_DIR" 25 | fi 26 | 27 | docker run -ti -v "$ROOT_DIR":/host --rm "$IMAGE_NAME" \ 28 | bash -c "(cd /usr/share/php/docs/pman && tar czf - .) | (cd /host && tar xzf -)" 29 | } 30 | 31 | if [[ '0' -eq "$#" ]] ; then 32 | sync 33 | elif [[ '1' -eq "$#" ]] ; then 34 | if [[ '--help' == "$1" ]] || [[ '-h' == "$1" ]] ; then 35 | usage "$0" 36 | elif [[ '--no-cache' == "$1" ]] ; then 37 | sync "--no-cache" 38 | fi 39 | fi 40 | 41 | usage "$0" 42 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "willdurand/pman", 3 | "description": "pear-doc.php.net/pman on Composer/Packagist", 4 | "license": "MIT", 5 | "authors": [ 6 | { 7 | "name": "William Durand", 8 | "email": "will+git@drnd.me" 9 | } 10 | ], 11 | "bin": [ 12 | "bin/pman", 13 | "bin/sync-pman" 14 | ] 15 | } 16 | --------------------------------------------------------------------------------