I'm possibly doing something totally wrong but I'm getting an error when trying to generate my documents.
I have a completely fresh installation of Laravel 5.1 which I have installed php documentor into via composer and when running the phpdoc command I get an error complaining about "PHPParser_NodeVisitor" not being found.
$ phpdoc run -d ./app/
Collecting files .. OK
Initializing parser .. OK
Parsing files
Parsing /var/www/www-admin/app/Http/Kernel.php
PHP Fatal error: Interface 'PHPParser_NodeVisitor' not found in /var/www/www-admin/vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/FileReflector.php on line 51
[2016-02-22 14:25:47] phpDocumentor.ALERT: Fatal Error (E_ERROR): Interface 'PHPParser_NodeVisitor' not found {"code":1,"message":"Interface 'PHPParser_NodeVisitor' not found","file":"/var/www/www-admin/vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/FileReflector.php","line":51} []
I get the same issue if I run against a single file "$ phpdoc -f AuthController.php"
Same here, tried with composer and phar versions but had the same error message.
Can you provide us the phpdocumentor version you are using?
@jaapio I've tried with the default that is pulled down via "$ composer require "phpdocumentor/phpdocumentor:2.*" and also specific version such as 2.8.5 and 2.7.1 all with the same issue.
@plapinski are you using Laravel? if so which version?
My feeling is it is an incompatibility with Laravel 5.1 as that pulls in https://github.com/nikic/PHP-Parser which might be conflicting although I could be looking in the wrong place.
@jaapio @saulhudson
I have tried current composer and phar, 2.8.4 pulled by composer and phar from 2.8.2. I use Laravel version 5.2.20. Each variant gives me same error message.
Same issue here. I'm using Laravel 5.2.20 as well.
Same issue here.
is there any temporary solution for this issue?
Not at current; we are still researching the issue
The issue seems to be happening because Laravel (at least 5.1 onwards) has a dependency on version 2.0 of PhpParser, which dropped the old aliases for lots of classes. Now it is fully "namespaced up" so the aliases don't work.
Doesn't sound like a phpdocumentor issue. We do not support any other version than phpParser ~0.9.5. In phpdocumentor 2. An upgrade is planned but not released yet.
I would advice you to download the phpdocumentor Phar and not install it via composer.
Yes, I agree - it's really a dependency clash between Laravel and phpDocumentor under composer. Looking in detail at the Laravel dependencies (my installation is v5.1 of the framework), it needs jeremeamia/SuperClosure which needs a minimum version of 1.0 of phpParser.
Edit: you can _kind of_ get past this by doing "composer --prefer-lowest nikic/php-parser", although strictly speaking, that ends up using php-parser v1.2.
Exactly for this reason we are planning a new installation method with phpDocumentor 3; you can add phpDocumentor 3 to your composer.json but instead of installing the sources it will install the phar file and a binary that calls that phar file
@mvriel +1 for that solution. It'd really help to not have as much dependency baggage.
@jaapio Thanks for investigating the issue and suggesting a solution. I'm sure the ideal solution for users is a simple composer require instead of manual installation using phar files.
@mvriel +1 for this solution as well
+1 for this
@mvriel :+1:
Most helpful comment
Doesn't sound like a phpdocumentor issue. We do not support any other version than phpParser ~0.9.5. In phpdocumentor 2. An upgrade is planned but not released yet.
I would advice you to download the phpdocumentor Phar and not install it via composer.