digilist / SnakeDumper

Anonymize your database dumps.
MIT License
49 stars 27 forks source link

Enable autoloading when install as dependency in a project #28

Closed emembeka closed 4 years ago

emembeka commented 4 years ago

Hi, I'm trying to install the SnakeDumper as a library inside an exististing project with > composer require digilist/SnakeDumper

Unfortunately the command vendor/bin/snakedumpercannot be executed because the autoload is not found.

$ vendor/bin/snakedumper 
PHP Warning:  require_once(/tmp/SD/vendor/digilist/snakedumper/bin/../vendor/autoload.php): failed to open stream: No such file or directory in /tmp/SD/vendor/digilist/snakedumper/bin/snakedumper on line 3
PHP Stack trace:
PHP   1. {main}() /tmp/SD/vendor/digilist/snakedumper/bin/snakedumper:0
PHP Fatal error:  require_once(): Failed opening required '/tmp/SD/vendor/digilist/snakedumper/bin/../vendor/autoload.php' (include_path='.:/usr/share/php') in /tmp/SD/vendor/digilist/snakedumper/bin/snakedumper on line 3
PHP Stack trace:
PHP   1. {main}() /tmp/SD/vendor/digilist/snakedumper/bin/snakedumper:0

I adjusted the executable by shamelessly copying the code from vendor/bin/doctrine-dbal which checks two locations for the autoloader. Now it can be executed correctely. A pull request will follow soon.

digilist commented 4 years ago

In the early days of SnakeDumper I considered this project as a project dependency as well, but imho it should not become a regular composer dependency, as it will interfere with actual project dependencies.

I think it would be better to install it separately or use the phar file (maybe I can create a package that installs the phar, similar to e.g. phpstan).

I am fine with merging the PR if you really want to, but I would recommend to install it not as a project dependency :)

emembeka commented 4 years ago

Hi digilist, yes, for me it is important, so I really like to have it included.

imho Managing the snake dumper as external dependency in a composer project makes it easier to keep the changes of this project inside a git-repository.

digilist commented 4 years ago

All right, I just merged the PR :)

emembeka commented 4 years ago

:-) Thank you