-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Add a link script to ease debugging Flex apps #24746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Could that be written in PHP, so that Windows user could use it easily also? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely 👍. It helped me already!
@dunglas ok to rewrite it in PHP? |
Yes I’ll try. |
@nicolas-grekas done. I don't have a Windows computer. It would be nice that someone test the new version on this OS. |
link
Outdated
} | ||
|
||
$sfPackages = array(); | ||
foreach (glob(__DIR__.'/src/Symfony/{Bundle,Bridge,Component}/*', GLOB_BRACE | GLOB_ONLYDIR | GLOB_NOSORT) as $dir) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GLOB_BRACE
doesn't work on some systems (Solaris), but I think it doesn't matter for this script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be we should put this binary in a bin/
folder?
link
Outdated
if ($argc < 2) { | ||
echo 'Link dependencies to components to a local clone of the monolithic Symfony repository'.PHP_EOL.PHP_EOL; | ||
echo 'Usage: link.php /path/to/the/project'.PHP_EOL; | ||
exit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exit(1);
the usage is wrong.
link
Outdated
|
||
if ($argc < 2) { | ||
echo 'Link dependencies to components to a local clone of the monolithic Symfony repository'.PHP_EOL.PHP_EOL; | ||
echo 'Usage: link.php /path/to/the/project'.PHP_EOL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the name of the file is link
so Usage: php link /path/
@lyrixx I've added this comment to the root directory for consistency with the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works like a charm! (ubuntu)
link
Outdated
} | ||
|
||
if (!is_dir("$argv[1]/vendor/symfony")) { | ||
echo "The directory \"$argv[1]\" does not exist or the dependencies are not installed, did you forget to run \"composer install\" in your project?"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing PHP_EOL
?
given The directory "foo" does not exist or the dependencies are not installed, did you forget to run "composer install" in your project?user@docker:/some/path$
link
Outdated
if (isset($sfPackages["symfony/$package"])) { | ||
rename($dir, "$dir.back"); | ||
symlink($sfDir = $sfPackages["symfony/$package"], $dir); | ||
echo "\"symfony/$package\" has been linked to \"$sfDir\"."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same.. missing EOL. Output is terrible ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I update (I didn't noticed because I use ZSH 😛).
link
Outdated
|
||
$package = basename($dir); | ||
if (isset($sfPackages["symfony/$package"])) { | ||
rename($dir, "$dir.back"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
intended as .bak
? https://en.wikipedia.org/wiki/Bak_file
Can/should we have an option to skip backup files, so no double classes are indexed in Phpstorm and such.
i'd prefer a ./link /some/path --backup
, but also fine for a --no-backup
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't care about the backup too.
Composer install is really fast when all packages are in cache
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same, I don't see the point of the backup. I'm always doing a rm -rf vendor/symfony/*.back
as it also messes up PhpStorm...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not for the speed, it's just in case the developper has done some changes in the vendor (common when trying to debug something). Ok for the --no-backup
flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but this fails when run twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh... maybe after adding another dependency...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but this fails when run twice
No because the second time it will be skipped (the symlink will already exists)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway I'm ok to remove the backup feature if nobody except me finds this hazardous :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drop :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
link
Outdated
*/ | ||
|
||
if (2 !== $argc) { | ||
echo 'Link dependencies to components to a local clone of the monolithic Symfony repository.' . PHP_EOL . PHP_EOL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not use "monolithic Symfony repository" as that's not something we are using anywhere else. What about just "the main symfony/symfony Github repository"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(even on 3.3 as that's the lowest supported Flex)
@dunglas is it possible to create relative symlinks? That would be convenient with docker. |
@ro0NL technically yes, but not on Windows AFAIK, so there need to be special care here. |
Rigth, but otherwise we could just exec |
"symlink" works just fine on Linux and Windows, no need for "exec" at all. |
How does it work with Docker with relative links? You put symfony/symfony in your project’s volume? What we can do is using relative links on Linux (for Docker) and absolute links on Windows. |
Yep :) basically i mount my entire
Sounds good :) im not sure if generating a rel path is a hassle? hence i suggested |
continue; | ||
} | ||
|
||
if (!isset($sfPackages[$package])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a message here: "Skipping ..., not a symfony/symfony package."?
also, should we make the script work with symfony/symfony? I'm sure it would help standard edition users.
Also wondering: where should we tell ppl that this script exists and when it should be used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for symlinking symfony/symfony as well. I think it fits the contributing section. That's what i'd use it for... cloning my symfony fork (so symlinks pointing here), adding symfony as 2nd upstream remote.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👎 for this "Skipping .. not a symfony package", it would be far too verbose and the output would be unreadable IMHO. If you really want to know, as a user, put a echo
in the PHP script or something I'd say.
👍 for symfony/symfony tho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can already rely on composer install --prefer-source
for symfony/symfony
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given this tool requires you to have a centralized clone somewhere, it's tempting to link it to multiple projects and switch branches on the fly :) i dont know if thats a supported use case, but if so symfony/symfony should be detected IMHO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can already rely on composer install --prefer-source for symfony/symfony.
I do as @ro0NL: one repo for dev, never touch directly inside vendor
Does the same can be achevied with composer local path repository ? https://getcomposer.org/doc/05-repositories.md#path |
@GromNaN yes, possible :) but i still think this script should work independent from composer. |
Works like a charm and it really saves the hack day for me. 👍 |
my use case is
for now i did
|
@ro0NL why don't you run the |
i do that 😉 i wrap therefor i get |
@ro0NL |
perhaps worth detecting availability... dunno. Or enable explicitly by 👍 for merging as is also.. i can change this manually now and then. |
Please merge with relative links support. We containerize each project we are working on and I believe lot of other people too. It will be very common use case. |
We don’t have a solution working both on Linux, BSD and Mac right now. I suggest to merge this PR as is because it’s a pain to debug Flex apps without, then we can try to add relative links support in another PR. |
We could simply I can confirm |
link
Outdated
|
||
if (2 !== $argc) { | ||
echo 'Link dependencies to components to a local clone of the main symfony/symfony GitHub repository.'.PHP_EOL.PHP_EOL; | ||
echo 'Usage: ./link /path/to/the/project'.PHP_EOL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe echo "Usage: $argv[0] /path/to/the/project".PHP_EOL;
should be used?
link
Outdated
* file that was distributed with this source code. | ||
*/ | ||
|
||
require 'src/Symfony/Component/Filesystem/Filesystem.php'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe require __DIR__.'/src/...'
?
link
Outdated
* file that was distributed with this source code. | ||
*/ | ||
|
||
require __DIR__.'src/Symfony/Component/Filesystem/Filesystem.php'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, but it seems '/' is missing: __DIR__.'/src/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works otherwise 👍
link
Outdated
exit(1); | ||
} | ||
|
||
$sfPackages = array('symfony' => __DIR__); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
symfony/symfony
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
real nice 👍 (any reason to not merge into lowest maintained branch?)
@ro0NL, no we'll merge it in the lowest branch directly using |
link
Outdated
} | ||
|
||
$sfPackages = array('symfony/symfony' => __DIR__); | ||
foreach (glob(__DIR__.'/src/Symfony/{Bundle,Bridge,Component}/*', GLOB_BRACE | GLOB_ONLYDIR | GLOB_NOSORT) as $dir) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing Security sub-components: src/Symfony/{Bundle,Bridge,Component,Component/Security}/*
👍 for merging this into 2.7, this is a tool for dev |
(squashing + rebasing before merging would be great) |
Thank you @dunglas. |
This PR was merged into the 2.7 branch. Discussion ---------- Add a link script to ease debugging Flex apps | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | #24708 | License | MIT | Doc PR | n/a (Reopened because of mishandling in the previous PR) It's painful to debug and patch Flex apps because `symfony/symfony` isn't installed by default (only components are) but PRs must be opened against the monolithic repository. This tiny tool, inspired by `npm link`, scan the `vendor/` directory of the project, and replace `symfony/` dependencies by symlinks to the local clone of the `symfony/symfony` repositories. Usage: ``` git clone git@github.com:symfony/symfony.git cd symfony ./link /path/to/the/project ``` Commits ------- 381f5d1 Add a "link" script to ease debugging Flex apps
This PR was merged into the 2.7 branch. Discussion ---------- Add example usage of the link script Docs for symfony/symfony#24746. Commits ------- 6051229 Add example usage of the link script
(Reopened because of mishandling in the previous PR)
It's painful to debug and patch Flex apps because
symfony/symfony
isn't installed by default (only components are) but PRs must be opened against the monolithic repository.This tiny tool, inspired by
npm link
, scan thevendor/
directory of the project, and replacesymfony/
dependencies by symlinks to the local clone of thesymfony/symfony
repositories.Usage: