Search code examples
phplaravel-5composer-phpphpdoc

PHPDoc with laravel


I'm trying to use PHPDoc in my Laravel project, but I'm having a bit of trouble getting it with composer. I run composer require phpdocumentor/phpdocumentor and receive the following:

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].

Allegedly, running composer update phpdocumentor/phpdocumentor nikic/php-parser should bring nikic/php-parser down to the version required by phpdoc, but that does not work because phpdoc is not yet installed.

I went into my vendor/ dir, and found the composer.json where nikic/php-parser is required, commented it out, composer update'd composer install'd so that phpdocumentor could require it, but no such luck.

What do you advise? How do I get PHPDoc into my project? Sorry if I'm being a fool!

Thanks!


Solution

  • Not a fool 😁...

    This output indicates that phpdocumentor/reflection specifically knows that it needs the older nikic/php-parser version, and cannot work with the newer version that is probably a minimum for laravel. Thus, composer protects you from yourself by saying no to the update 😉

    I'd say the easiest workaround here would be to download the PHAR binary [1] and put it in ./vendor/bin. That way, it's in the same place as the executable that you'd normally have (./vendor/bin/phpdoc). If you're on a Unix variant, you can symlink the PHAR so that you can call it in the same way.

    [1] -- http://phpdoc.org/phpDocumentor.phar