Skip to content

Conversation

jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Feb 23, 2020

If you git clone the repo and run composer install and then call the program like so:

php path/to/gitclone/parallel-lint

For a non-composer based project, PHP-Parallel-Lint would fail with the following message:

You must set up the project dependencies, run the following commands:
curl -s http://getcomposer.org/installer | php
php composer.phar install

For a composer based project, i.e. which does have a vendor/autoload.php file, but that file may not contain references to the PHP-Parallel-Lint application, it would fail with the following hard error:

Fatal error: Uncaught Error: Class 'JakubOnderka\PhpParallelLint\Application' not found in path/to/gitclone/parallel-lint:66

This small change allows the application to work correctly in that situation.

This is the same PR as previously pulled in PR JakubOnderka/PHP-Parallel-Lint#149

If you git clone the repo and run `composer install` and then call the program like so:
```bash
php path/to/gitclone/parallel-lint
```

For a non-composer based project, PHP-Parallel-Lint would fail with the following message:
```
You must set up the project dependencies, run the following commands:
curl -s http://getcomposer.org/installer | php
php composer.phar install
```

For a composer based project, i.e. which does have a `vendor/autoload.php` file, but that file may not contain references to the PHP-Parallel-Lint application, it would fail with the following hard error:
```
Fatal error: Uncaught Error: Class 'JakubOnderka\PhpParallelLint\Application' not found in path/to/gitclone/parallel-lint:66
```

This small change allows the application to work correctly in that situation.
$autoloadLocations = [
getcwd() . '/vendor/autoload.php',
getcwd() . '/../../autoload.php',
__DIR__ . '/vendor/autoload.php',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a similar case.
If you call the script from outside your project folder, the same error message appears.
e.g. my-project-in-subfolder/vendor/bin/parallel-lint

This would fix it:

Suggested change
__DIR__ . '/vendor/autoload.php',
__DIR__ . '/vendor/autoload.php',
__DIR__ . '/../../autoload.php',

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there are basically more issues with the autoloading. PR #2 was also a step in the right direction, but a more structural, stable solution is needed.

@jrfnl
Copy link
Collaborator Author

jrfnl commented Mar 25, 2020

Same fix applied in commit de81f0a

@jrfnl jrfnl closed this Mar 25, 2020
@jrfnl jrfnl deleted the feature/allow-running-as-git-clone- branch March 25, 2020 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants