春咲さんのメモ。

自分メモ的な。主にPHPについて。github:mindlessdoll(冬眠してるけど)

phpDocumentorがComposerで入らなかった時のメモ

環境:CentOS7、Laravel5.5、php7.1

composer require --dev phpdocumentor/phpdocumentor

↑これがうまくいかない

こんなエラーが出る

    Using version ^2.9 for phpdocumentor/phpdocumentor
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for phpdocumentor/phpdocumentor ^2.9 -> satisfiable by phpdocumentor/phpdocumentor[v2.9.0].
    - Conclusion: remove nikic/php-parser v3.1.1
    - Conclusion: don't install nikic/php-parser v3.1.1
    - phpdocumentor/phpdocumentor v2.9.0 requires phpdocumentor/reflection ^3.0 -> satisfiable by phpdocumentor/reflection[3.0.0, 3.0.1].
    - phpdocumentor/reflection 3.0.0 requires nikic/php-parser ^1.0 -> satisfiable by nikic/php-parser[v1.0.0, v1.0.1, v1.0.2, v1.1.0, v1.2.0, v1.2.1, v1.2.2, v1.3.0, v1.4.0, v1.4.1].
    - phpdocumentor/reflection 3.0.1 requires nikic/php-parser ^1.0 -> satisfiable by nikic/php-parser[v1.0.0, v1.0.1, v1.0.2, v1.1.0, v1.2.0, v1.2.1, v1.2.2, v1.3.0, v1.4.0, v1.4.1].
    - Can only install one of: nikic/php-parser[v1.3.0, v3.1.1].
    - Can only install one of: nikic/php-parser[v1.4.0, v3.1.1].
    - Can only install one of: nikic/php-parser[v1.4.1, v3.1.1].
    - Can only install one of: nikic/php-parser[v1.0.0, v3.1.1].
    - Can only install one of: nikic/php-parser[v1.0.1, v3.1.1].
    - Can only install one of: nikic/php-parser[v1.0.2, v3.1.1].
    - Can only install one of: nikic/php-parser[v1.1.0, v3.1.1].
    - Can only install one of: nikic/php-parser[v1.2.0, v3.1.1].
    - Can only install one of: nikic/php-parser[v1.2.1, v3.1.1].
    - Can only install one of: nikic/php-parser[v1.2.2, v3.1.1].
    - Installation request for nikic/php-parser (locked at v3.1.1) -> satisfiable by nikic/php-parser[v3.1.1].


Installation failed, reverting ./composer.json to its original content.

参考にしたサイト(英語)ここに理由も書いてあります。

https://stackoverflow.com/questions/46339362/phpdoc-with-laravel

 

解決手順としては、

  1. http://phpdoc.org/phpDocumentor.phar ここからphpDocumentor.pharを取得
  2. 上記をvendor/binに配置する

以上です。

使い方は

php vendor/bin/phpDocumentor.phar -d 生成したいファイルがあるディレクト

↑のs例ではディレクディレクトリを指定していますが、ファイル単体でいい時いい時は、、-dオプションでなくて-fオプションにして、ファイルパスを指定します。

 使い方が普通に入れた場合と異なるので気をつけていただければなと(phpdocコマンド使えなかった。pharで入れたから当たり前なのかな? よくわからない)。