mirror of
https://github.com/DBDiff/DBDiff.git
synced 2026-04-25 13:25:49 +03:00
[GH-ISSUE #73] Add ability to install dbdiff globally (via 1: composer global require, and 2. PHAR) #51
Labels
No labels
bug
enhancement
good first issue
help wanted
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/DBDiff#51
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @plashenkov on GitHub (Feb 20, 2018).
Original GitHub issue: https://github.com/DBDiff/DBDiff/issues/73
Hi!
It would be nice to have self-sufficient phar which we then can simply copy to our
binfolder and use it from anywhere. And there will be no need tocomposer install, etc.An example can be seen here: https://github.com/banago/PHPloy
(see
distfolder)As a bonus there will be no more issues like, for example, this: https://github.com/DBDiff/DBDiff/issues/72
@plashenkov commented on GitHub (Feb 23, 2018):
Let's add an ability to install dbdiff globally via:
composer global require "dbdiff/dbdiff:@dev"This will allow the user to use dbdiff as a "binary" from anywhere in the system. I can create
.dbdiffconfig file under each project folder and then just run dbdiff as a standalone tool from command-line (without copying it to each project).Installing globally via composer will allow us to easily update dbdiff (
composer global update); installing globally as a phar self-sufficient executable also has its advantages: there will be no conflicts of dependencies if there are other libraries in the global composer space.What do we need to update to achieve this?
Let's use
getcwd()to get current working directory from which dbdiff is executed:When dbdiff is installed using composer, dbdiff is located inside the vendor directory, and we should look for
autoload.phpwhere it is really located. When dbdiff is installed by cloning/downloading Git repository and then usingcomposer install, thevendordirectory is located alongsidedbdiffexecutable. We should consider both variants. Let's do this:It's always a good idea to use
__DIR__(orgetcwd()) instead of ambiguous relative paths.@plashenkov commented on GitHub (Feb 24, 2018):
We need to make a copy of
dbdiff(in the repository root) and name itdbdiff.php. Then delete the first line (#!/usr/bin/env php) and use the following composer autoload:(this single line is enough here as we will use this
dbdiff.phpfile only in PHAR).Then create
buildexecutable in repo root with the following content:Now, running
./buildwill createdbdiff.pharfile insidedistfolder.@plashenkov commented on GitHub (Feb 24, 2018):
The previous actions will produce fully working PHAR as well as global dbdiff installation. I hope you will find them really useful. If you want, I can create a pull request. But I thought the detailed explanation will be relevant.
I believe the following step should be to add an ability to specify what to compare inside
.dbdifffile. Often we need a simple complete databases comparison. It's annoying to type them as parameters every time (their names are different from project to project, their names are different on server1 and server2, etc., and I do not remember them, I need to open DB client and connect to databases to see their names). I want to simply rundbdiffinside project folder to get themigration.sql. And if I want to compare something special, I use parameters (which should override default settings from.dbdiff). But this is for a separate issue, I think.@jasdeepkhalsa commented on GitHub (Feb 24, 2018):
Thanks for the extremely detailed comments @plashenkov . We have a few things in the pipeline to address first but will get onto this ! In the meantime if you'd like to raise a PR for this, we can prioritise getting it merged in :)
@tennox commented on GitHub (Sep 6, 2018):
Any updates on this?
It would be really amazing to be able to download a .phar executable - especially for CI environments.
If I find time I will try to create this PR myself, but at the moment I don't have any.
@plashenkov commented on GitHub (Sep 7, 2018):
Forked. I'll add a PR ASAP. Approx. 1–3 days
@plashenkov commented on GitHub (Sep 14, 2018):
I've added a PR. As described,
1. We will be able to install DBDiff globally using:
2. Or we can build and use a Phar:
composer install./build/usr/local/bin, for example.@plashenkov commented on GitHub (Mar 18, 2019):
Hey @jhbsk! I am happy to see you are with us again :)
Any news on this? :)
@jasdeepkhalsa commented on GitHub (Mar 19, 2019):
Thanks @plashenkov for all the hard work on the PR.
My only reservation to merging it in is that I never had a chance to complete some basic tests (using PHPUnit) around functionality, as I want to make sure nothing regresses. Have you already thoroughly tested this change?
Also...just need to add your steps into the documentation README file - which i can do no problem!
Thanks again @plashenkov
@plashenkov commented on GitHub (Mar 20, 2019):
Hi @jhbsk!
Well, this PR adds two files which do not affect current functionality at all; and two other small edits are described in my second post of this thread. I am not too good at automatic tests like PHPUnit, etc., but all edits contained in this PR are carefully tested by me, of course. I use this new customized DBDiff build for a relatively long time already and it works very well and as expected.
All added and changed files: https://github.com/DBDiff/DBDiff/pull/86/files (for convenience)
@ThaDaVos commented on GitHub (Feb 3, 2020):
Any ETA on the merge/addition of this functionality? Would be so amazing!