Skip to content

Run the run.php script from within any directory #78

@MetalArend

Description

@MetalArend

First of all: big thanks for this awesome tool!

Trying it out however, I have run into a small problem with using relative paths. Running the following line:

php /composer/vendor/phpcheckstyle/phpcheckstyle/run.php --src "./src"

I receive the error

Fatal error: Uncaught Error: Class 'PHPCheckstyle\PHPCheckstyle' not found in /composer/vendor/phpcheckstyle/phpcheckstyle/run.php:172
Stack trace:
#0 {main}
  thrown in /composer/vendor/phpcheckstyle/phpcheckstyle/run.php on line 172

Trying to load the /composer/vendor/autoload.php solves this, but it will still complain about not finding the default config file, as it is defined relatively to the location the script is run from, not relatively to the script itself.

This dependency on the location where php is run from is found on other lines as well:

Is there some way to update run.php to make the script run from anywhere? Or even make it possible to run it as a binary in /composer/vendor/bin (which might take advantage from these same changes)? Honestly, I'm not really sure if these would be the only changes needed to being able to run the above line, as --src "./src" is still using a relative path to the location the script has been called from...

Thanks for looking into this. I would be glad to help to provide further details if needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions