lorisleiva / laravel-docker

🐳 Generic docker image for Laravel Applications
MIT License
934 stars 314 forks source link

phpcs fails on latest version #20

Closed pixelplant closed 5 years ago

pixelplant commented 5 years ago
phpcs --standard=PSR2 --extensions=php --ignore=".(blade.php)" app
/bin/bash: line 78: phpcs: command not found

I saw that codesniffer is now installed using composer, but changing the line to

./vendor/bin/phpcs --standard=PSR2 --extensions=php --ignore=".(blade.php)" app
/bin/bash: line 78: ./vendor/bin/phpcs: No such file or directory

did not fix the issue.

Is there something I'm missing?

pixelplant commented 5 years ago

Seems the new path should be

~/.composer/vendor/bin/phpcs --standard=PSR2 --extensions=php --ignore=".(blade.php)" app
lorisleiva commented 5 years ago

Thanks for raising this! I've add to change the way PHPCS is installed and I didn't think about this consequence. Let me know if you can think of a way to set it up back to the way it was.

fgilio commented 5 years ago

Oh crap didn't think about this when making the change. ~@lorisleiva time you update your post? 😅~

~The fix should be as easy a adding export PATH=~/.composer/vendor/bin:$PATH to the equivalent of ~/.bash_profile.~ I see that line 60 already does something similar.

I've seem people doing it like this:

# First set COMPOSER_HOME environment variable, will be picked up by Composer during install
ENV COMPOSER_HOME /composer
# Then add the global binary directory to PATH
ENV PATH /composer/vendor/bin:$PATH
# And finally install composer
....

I guess this is the same as in line 60, but maybe the dir is not ./vendor/bin. I like that the COMPOSER_HOME way makes it super explicit.

AngeloAvv commented 5 years ago

Here I am with the very same error!

phpcs --standard=PSR2 --extensions=php --ignore=app/Console/*,app/Support/helpers.php app
/bin/bash: line 66: phpcs: command not found

So what's the best way to set it back properly?

fgilio commented 5 years ago

Until this is properly fixed in the image, @pixelplant solution should work ~/.composer/vendor/bin/phpcs. And it should continue working when the image is fixed

lorisleiva commented 5 years ago

@fgilio Amazing, thanks for sharing this piece of code. I'll update the dockerfiles to make the composer directory explicit.

I'm going to reopen this until it works.

fgilio commented 5 years ago

@AngeloAvv @pixelplant have you had a chance to test with the latest version? I don't have any project with the CI running the phpcs job

pixelplant commented 5 years ago

@fgilio Yes, it works now without specifying the complete path to phpcs, like before.

fgilio commented 5 years ago

Awesome! Thanks for the update

lorisleiva commented 5 years ago

Perfect. Thanks everyone for your help in this issue.

HighCoData commented 5 years ago

I'm still having issues after clearing all cache and rebuilding the composer package.... None of the applicaitons in vendor/bin are not accasible.

I'm using the latest image

lorisleiva commented 5 years ago

I've added back the ./vendor/bin path in the $PATH variable.

Please let me know if it works once the new images have been built. 🤞

bseresia commented 5 years ago

No image fixed this as well.. Thanks!

lorisleiva commented 5 years ago

@HighCoData Is your issue fixed by the latest image?

HighCoData commented 5 years ago

yes it is, thanks

AngeloAvv commented 2 years ago

@lorisleiva seems like the issue is back again with the following image:

lorisleiva/laravel-docker:7.4