Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php documentor version 3 is not using configuration file #2018

Closed
tflori opened this issue Sep 14, 2018 · 15 comments
Closed

php documentor version 3 is not using configuration file #2018

tflori opened this issue Sep 14, 2018 · 15 comments
Assignees

Comments

@tflori
Copy link

tflori commented Sep 14, 2018

Expected Behavior

I have a configuration file that defines another target for the parser, another target for the transformer and a template. I expect that it still works or at least the documentation says how to configure this now and what needs to be changed for version 3.

Actual Behavior

It renders the default template to the default path which is useless for me.

Steps to Reproduce the Problem

  1. Create a custom template
  2. Create a configuration file
  3. run phpDocumentor v3 with -c <path-to-config.xml>

Your environment

  • Version used: 3.0.0-alpha.2
  • Install method: downloaded .phar with public key
  • php version 7.2.9
  • Operating system: Manjaro (rolling release)
  • Link to your project: https://github.com/tflori/orm
<?xml version="1.0" encoding="UTF-8" ?>
<phpdoc>
    <parser>
        <target>/tmp/phpdoc/orm</target>
    </parser>
    <transformer>
        <target>docs</target>
    </transformer>
    <transformations>
        <template name="docs/_reference"/>
    </transformations>
    <files>
        <directory>src</directory>
    </files>
</phpdoc>
@tflori
Copy link
Author

tflori commented Sep 14, 2018

I don't know if it is related but also defining these configurations as command line argument does not bring the expected result: it parses the correct folder and then just outputs nothing with the information:

$ phpDocumentor.phar run -d src/ -t docs --template "docs/_reference" --force
...
08:14:38 INFO      [app] 
Applying 0 transformations [] []
08:14:38 INFO      [app] Finished transformation process [] []

Also the debug mode (-vvv) does not give a hint why no transformations are executed.

@mvriel
Copy link
Member

mvriel commented Sep 14, 2018

I am currently working on a story to rework the way configuration works. Part of that is to make sure that all elements of it function.

In short, my current hypothesis is that this has to do with how phar works. phpDocumentor tries to retrieve the file from within the phar archive instead of outside of it. Unfortunately, that is a hypothesis and I hope to have more information soon

@mvriel
Copy link
Member

mvriel commented Sep 23, 2018

I have just pushed changes to re-enable the use of an external configuration file. This is on develop and has no phar as of yet.

@mvriel mvriel self-assigned this Sep 23, 2018
@tflori
Copy link
Author

tflori commented Sep 25, 2018

I'm just trying it. The first problem: it expects a phpdocumentor root element in the xml file:

In Version2.php line 329: Root element name should be phpdocumentor, phpdoc found

@tflori
Copy link
Author

tflori commented Sep 25, 2018

It seems to read the config file now but I don't know what to expect from this development version. Currently I get this error:

$ env APP_ENV=dev /tmp/phpDocumentor2/bin/phpdoc project:run -c phpdoc.xml -vvv
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 46.00 megabytes (+47,104 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 46.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 46.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 46.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 46.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 46.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 46.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 46.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 46.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 46.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 46.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+2,048 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 48.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 50.00 megabytes (+2,048 kilobytes) [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 50.00 megabytes (+0 kilobytes) [] []
[2018-09-25 06:36:25] app.INFO: Starting to parse file: src/EntityManager.php [] []
[2018-09-25 06:36:25] app.INFO: Parsing src/EntityManager.php [] []
[2018-09-25 06:36:25] app.ALERT:   Unable to parse file "src/EntityManager.php", an error was detected: "\ORM\EntityManager[string]" is not a valid Fqsen. [] []
[2018-09-25 06:36:25] app.DEBUG: >> Memory after processing of file: 52.00 megabytes (+2,048 kilobytes) [] []

In Project.php line 81:
                                                                                                                                                                                                                                                                           
  [Symfony\Component\Debug\Exception\FatalThrowableError]                                                                                                                                                                                                                  
  Argument 1 passed to phpDocumentor\Reflection\Php\Project::addFile() must be an instance of phpDocumentor\Reflection\Php\File, null given, called in /tmp/phpDocumentor2/vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Php/ProjectFactory.php on line 79  
                                                                                                                                                                                                                                                                           

Exception trace:
 phpDocumentor\Reflection\Php\Project->addFile() at /tmp/phpDocumentor2/vendor/phpdocumentor/reflection/src/phpDocumentor/Reflection/Php/ProjectFactory.php:79
 phpDocumentor\Reflection\Php\ProjectFactory->create() at /tmp/phpDocumentor2/src/phpDocumentor/Parser/Parser.php:276
 phpDocumentor\Parser\Parser->parse() at /tmp/phpDocumentor2/var/cache/dev/Container5ZQxJf3/Parser_37328e3.php:170
 Parser_37328e3->parse() at /tmp/phpDocumentor2/src/phpDocumentor/Application/Stage/Parser.php:165
 phpDocumentor\Application\Stage\Parser->__invoke() at n/a:n/a
 call_user_func() at /tmp/phpDocumentor2/vendor/league/pipeline/src/FingersCrossedProcessor.php:16
 League\Pipeline\FingersCrossedProcessor->process() at /tmp/phpDocumentor2/vendor/league/pipeline/src/Pipeline.php:59
 League\Pipeline\Pipeline->process() at /tmp/phpDocumentor2/vendor/league/pipeline/src/Pipeline.php:67
 League\Pipeline\Pipeline->__invoke() at n/a:n/a
 call_user_func() at /tmp/phpDocumentor2/vendor/league/pipeline/src/FingersCrossedProcessor.php:16
 League\Pipeline\FingersCrossedProcessor->process() at /tmp/phpDocumentor2/vendor/league/pipeline/src/Pipeline.php:59
 League\Pipeline\Pipeline->process() at /tmp/phpDocumentor2/vendor/league/pipeline/src/Pipeline.php:67
 League\Pipeline\Pipeline->__invoke() at /tmp/phpDocumentor2/src/phpDocumentor/Application/Console/Command/Project/RunCommand.php:249
 phpDocumentor\Application\Console\Command\Project\RunCommand->execute() at /tmp/phpDocumentor2/vendor/symfony/console/Command/Command.php:251
 Symfony\Component\Console\Command\Command->run() at /tmp/phpDocumentor2/vendor/symfony/console/Application.php:904
 Symfony\Component\Console\Application->doRunCommand() at /tmp/phpDocumentor2/vendor/symfony/framework-bundle/Console/Application.php:89
 Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at /tmp/phpDocumentor2/vendor/symfony/console/Application.php:262
 Symfony\Component\Console\Application->doRun() at /tmp/phpDocumentor2/vendor/symfony/framework-bundle/Console/Application.php:75
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /tmp/phpDocumentor2/vendor/symfony/console/Application.php:145
 Symfony\Component\Console\Application->run() at /tmp/phpDocumentor2/bin/phpdoc:44

@jaapio
Copy link
Member

jaapio commented Oct 20, 2018

Thanks for this feedback @tflori. We fixed the second reported issue.

@in4s
Copy link

in4s commented Nov 5, 2018

Sorry for my english... this issue fixed at Release v3.0.0-alpha.3 or not? it still dont use correct target directory from the file. (but the flag -t is working correctly)

@Jelmerb
Copy link

Jelmerb commented Apr 2, 2019

I can't figure out how use an external configuration file with the phar file from version 3.0.0-alpha3. Can anyone help me in the right direction?

@jaapio
Copy link
Member

jaapio commented Apr 2, 2019

The current phar is not working correctly. We need to create a new release to provide a new phar. You could try the install latest version from the develop branch. Using composer.

@Jelmerb
Copy link

Jelmerb commented Apr 3, 2019

I tried it but I get conflicts with composer packages that require newer versions of certain packages.
I required these packages in the require-dev section of composer.json

 "phpdocumentor/phpdocumentor": "dev-develop@dev",
        "phpdocumentor/flyfinder": "1.*@beta",
        "phpdocumentor/graphviz": "2.*@alpha",
        "phpdocumentor/reflection-common": "2.*@alpha",
        "phpdocumentor/reflection-docblock": "5.*@alpha",
        "phpdocumentor/reflection": "4.*@alpha",
        "symfony/lts": "^4@dev" 

Installing these packages gives the following composer log:

Problem 1
     - symfony/serializer-pack v1.0.2 requires phpdocumentor/reflection-docblock ^3.0|^4.0 -> satisfiable by phpdocumentor/reflection-docblock[3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.1.0, 3.1.1, 3.2.0, 3.2.1, 3.2.2, 3.2.3, 3.3.0, 3.3.2, 4.0.0, 4.0.1, 4.1.0, 4.1.1, 4.2.0, 4.3.0] but these conflict with your requirements or minimum-stability.
     - symfony/serializer-pack v1.0.1 requires phpdocumentor/reflection-docblock ^3.0|^4.0 -> satisfiable by phpdocumentor/reflection-docblock[3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.1.0, 3.1.1, 3.2.0, 3.2.1, 3.2.2, 3.2.3, 3.3.0, 3.3.2, 4.0.0, 4.0.1, 4.1.0, 4.1.1, 4.2.0, 4.3.0] but these conflict with your requirements or minimum-stability.
     - symfony/serializer-pack v1.0.0 requires phpdocumentor/reflection-docblock ^3.0|^4.0 -> satisfiable by phpdocumentor/reflection-docblock[3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.1.0, 3.1.1, 3.2.0, 3.2.1, 3.2.2, 3.2.3, 3.3.0, 3.3.2, 4.0.0, 4.0.1, 4.1.0, 4.1.1, 4.2.0, 4.3.0] but these conflict with your requirements or minimum-stability.
     - symfony/serializer-pack v1.0.2 requires phpdocumentor/reflection-docblock ^3.0|^4.0 -> satisfiable by phpdocumentor/reflection-docblock[3.0.0, 3.0.1, 3.0.2, 3.0.3, 3.1.0, 3.1.1, 3.2.0, 3.2.1, 3.2.2, 3.2.3, 3.3.0, 3.3.2, 4.0.0, 4.0.1, 4.1.0, 4.1.1, 4.2.0, 4.3.0] but these conflict with your requirements or minimum-stability.
     - Installation request for symfony/serializer-pack 1.0.* -> satisfiable by symfony/serializer-pack[v1.0.0, v1.0.1, v1.0.2].

Is there a way to get around this problem?

@jaapio
Copy link
Member

jaapio commented Apr 3, 2019

The only thing I can think of is installing phpdocumentor in a separate directory. We do not recommend installing phpdocumentor in a project because of the number of conflicts you encounter and others did in the past

@Jelmerb
Copy link

Jelmerb commented Apr 4, 2019

Okay, did what you suggested. I ran the command:

$ phpDocumentor/bin/phpdoc -c sead/phpdoc.dist.xml

It did say it used the provided configuration file. But no files are created anywhere.
This is the output:

[09:19:10]: Using the configuration file at: sead/phpdoc.dist.xml
[09:19:10]: Collecting files .. 
[09:19:32]: OK
[09:19:32]: Parsing files
[09:19:32]: Elapsed time to parse all files: 0.01s
[09:19:32]: Peak memory usage: 20M
[09:19:32]: Storing cache .. 
[09:19:32]: OK
[09:19:32]: Using the configuration file at the default location
[09:19:33]:  Applying 17 transformations
[09:19:33]:   Initialize writer "phpDocumentor\Plugin\Core\Transformer\Writer\FileIo"
[09:19:33]:   Initialize writer "phpDocumentor\Plugin\Twig\Writer\Twig"
[09:19:33]:   Initialize writer "phpDocumentor\Plugin\Graphs\Writer\Graph"
[09:19:33]:   Writer FileIo  using query "copy" on .htaccess
[09:19:33]:   Writer FileIo  using query "copy" on images
[09:19:33]:   Writer FileIo  using query "copy" on css
[09:19:33]:   Writer FileIo  using query "copy" on js
[09:19:33]:   Writer FileIo  using query "copy" on font
[09:19:33]:   Writer twig  using query "namespace" on index.html
[09:19:33]:   Writer twig  using query "indexes.namespaces" on 
[09:19:33]:   Writer twig  using query "indexes.classes" on 
[09:19:33]:   Writer twig  using query "indexes.interfaces" on 
[09:19:33]:   Writer twig  using query "indexes.traits" on 
[09:19:33]:   Writer twig  using query "files" on 
[09:19:33]:   Writer twig  using query "files" on files/{{path}}.txt
[09:19:33]:   Writer twig  on reports/markers.html
[09:19:33]:   Writer twig  on reports/errors.html
[09:19:33]:   Writer twig  on reports/deprecated.html
[09:19:33]:   Writer twig  on graphs/class.html
[09:19:33]:   Writer Graph  on graphs/classes.svg
[09:19:33]: Finished transformation process
[09:19:33]: In the ProjectDescriptor are:          0 files          0 top-level namespaces          0 unresolvable parent classes          1 phpDocumentor\Descriptor\NamespaceDescriptor elements 

And this is my xml file which is at the root of the project I want to generate documentation for

<?xml version="1.0" encoding="UTF-8" ?>
<phpdocumentor>
    <parser>
        <target>docs</target>
    </parser>
    <transformer>
        <target>docs</target>
    </transformer>
    <files>
        <directory>src</directory>
        <ignore>src/Kernel.php</ignore>
        <ignore>src/Migrations/*</ignore>
        <ignore>src/Repository/*</ignore>
    </files>
    <title>SEAD Documentation</title>
</phpdocumentor>

Do I have to place the configuration file somewhere else and/or change the paths of the files, transformer and parser section of the configuration?

@jaapio
Copy link
Member

jaapio commented Apr 4, 2019

The source path is relative to the director where you start phpdocumentor. With this configuration you should be in the directory sead, I expect that to be the root of your project 😄

@Jelmerb
Copy link

Jelmerb commented Apr 4, 2019

That is indeed the root of my project. Thank you sir, it worked. I thought the source paths where relative to the configuration file. I read that somewhere in the documentation on docs.php.org.

@jaapio
Copy link
Member

jaapio commented Apr 4, 2019

I am glad to hear that it worked for you. Thanks for having us. And that you took your time to create an issue.

@mvriel mvriel closed this as completed Jun 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants