bruli / php-git-hooks

Git hooks for PHP projects
MIT License
676 stars 107 forks source link

Symfony 5 support #135

Open kacperjurak opened 4 years ago

kacperjurak commented 4 years ago

Hello, Is there a chance for Symfony 5 support? Best Regards

root@a0f26d661718:/var/www/html# composer require bruli/php-git-hooks --dev
Using version ^5.9 for bruli/php-git-hooks
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "5.0.*"
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for bruli/php-git-hooks ^5.9 -> satisfiable by bruli/php-git-hooks[v5.9].
    - bruli/php-git-hooks v5.9 requires symfony/dependency-injection ~4.0 -> no matching package found.
afasciaux commented 3 years ago

Hi, Same here but no answer since 1 year, seems no fix for SF 5 support ?

carlos-mg89 commented 3 years ago

It's been a while since Symfony 5 got out there, and now we're in Symfony 5.2, with 5.3 about to be released.

I understand the project might be out of interest for the maintainer, but if you read this, I might be able to help with a PR that deals with this compatibility upgrade for Symfony 5.X. I would only need a confirmation that you will review the PR and if it tests pass and you think is valuable, then publish a new release.

Thanks in advance

P.S. In case the maintainer is busy, does anyone know a replacement for this package that performs similar tasks and is compatible with Symfony 5.x ?

carlos-mg89 commented 3 years ago

I've managed to find a really nice alternative to this dependency. pre-commit software is described as:

A framework for managing and maintaining multi-language pre-commit hooks

So this is a replacement not only for this project, which is PHP focused, but to many programming languages.

I've been playing with it, and the setup is very simple:

  1. Install pre-commit => https://pre-commit.com/#install
  2. Create a .pre-commit-config.yaml file in the root of your project
  3. As described in the official page ( https://pre-commit.com/hooks.html ), check your programming languages hooks, since it's quite likely that someone else has already set this up for you. It's the case for PHP: https://github.com/digitalpulp/pre-commit-php

This is the setup I've implemented for my Symfony 5 project:

repos:
  - repo: https://github.com/digitalpulp/pre-commit-php.git
    rev: 1.4.0
    hooks:
      - id: php-lint-all
      - id: php-unit
      - id: php-cs
        files: \.(php)$
        args: [ --standard=PSR2 -p ]

You can manually run the hook with this command:

pre-commit run --all-files

Or simply wait until you make a commit, and see the automated run of the above command :)

Have fun!