phpmetrics / PhpMetrics

Beautiful and understandable static analysis tool for PHP
https://phpmetrics.github.io/website/
MIT License
2.48k stars 259 forks source link

Quick Start instructions: phpmetrics should run as Bash, not PHP #491

Closed chris407x closed 1 year ago

chris407x commented 1 year ago

Thanks for this software. It is awesome. I found that this instruction did not work for me:

# install the package as a dev dependency
composer require phpmetrics/phpmetrics --dev

# run PHPMetrics to analyze a folder and generate a report
php ./vendor/bin/phpmetrics --report-html=myreport <folder-to-analyze>

the file to run is a bash file so it should be sh ./vendor instead of php ./vendor:

# install the package as a dev dependency
composer require phpmetrics/phpmetrics --dev

# run PHPMetrics to analyze a folder and generate a report
sh ./vendor/bin/phpmetrics --report-html=myreport <folder-to-analyze>
niconoe- commented 1 year ago

Hi @chris407x and thank you for using PhpMetrics!

Could you please tell be which version of PhpMetrics you have installed via your composer installation? With the release of the version 3.0.0rc1, the command composer require phpmetrics/phpmetrics --dev will either install the version 3.0.0rc1 or the version 2.8.2 depending on the minimum-stability strategy you defined.

I found that this instruction did not work for me:

Can you tell me what error the php call gives to you please? I'm sure this should work this way.

the file to run is a bash file so it should be sh ./vandor instead of PHP ./vendor:

No, the file is not a bash file. It contains a shebang so that if and only if you run it via any shell (bash, ksh, zsh, native sh,…), the shell process must run this file using the command defined in the shebang instead. That means it will internally run php ./vendor/bin/phpmetrics just like you did.

Please give me more information so that I could help you to solve your issue.

Thanks a lot!

chris407x commented 1 year ago

Hi, well, I figured it out for myself (and my situation) and was able to run it. I followed the instructions like a monkey and cut and pasted them into my VM on Windows running CentOS 7.x (I think) with PHP 7.4. When I ran the command as written, the file's contents echoed out: as If I tried to run a text file with php -f textFile.txt. When I noticed this I tried again using sh and it worked. This may be unique to my situation/configuration and did not make sense for a full-blown pull request. I can do more troubleshooting if you would like, but I am all set. Thanks for the prompt reply; this tool is awesome. I am running it against a huge 20-year-old code base so it is really getting a workout.

niconoe- commented 1 year ago

Ok, thank you for your feedback :slightly_smiling_face:

I can find similar issues like yours online about PHP being treated as text rather than being interpreted, but usually related to Apache misconfiguration, which is not your case here, so I'm really confused about it.

What I can do, if you like, would be to update the documentation to say that, if it doesn't work with the php command, one can run the sh command instead.

Would it be OK to you?

chris407x commented 1 year ago

Yes that sounds like a great solution! Thank you!

On Fri, Apr 14, 2023 at 2:51 AM Nicolas Giraud @.***> wrote:

Ok, thank you for your feedback 🙂

I can find similar issues like yours online about PHP being treated as text rather than being interpreted, but usually related to Apache misconfiguration, which is not your case here, so I'm really confused about it.

What I can do, if you like, would be to update the documentation to say that, if it doesn't work with the php command, one can run the sh command instead.

Would it be OK to you?

— Reply to this email directly, view it on GitHub https://github.com/phpmetrics/PhpMetrics/issues/491#issuecomment-1508012664, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPC22OPQNYEGLIS7X4KAOTXBDXWNANCNFSM6AAAAAAW4JDUKI . You are receiving this because you were assigned.Message ID: @.***>

-- Chris Adams @.*** 407-538-8475

niconoe- commented 1 year ago

Fixed by https://github.com/phpmetrics/PhpMetrics/releases/tag/v3.0.0rc2