-
-
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
require __DIR__.'/src/Symfony/Component/Filesystem/Exception/ExceptionInterface.php'; | ||
require __DIR__.'/src/Symfony/Component/Filesystem/Exception/IOExceptionInterface.php'; | ||
require __DIR__.'/src/Symfony/Component/Filesystem/Exception/IOException.php'; | ||
require __DIR__.'/src/Symfony/Component/Filesystem/Filesystem.php'; | ||
|
||
use Symfony\Component\Filesystem\Filesystem; | ||
|
||
/** | ||
* Links dependencies to components to a local clone of the main symfony/symfony GitHub repository. | ||
* | ||
* @author Kévin Dunglas <dunglas@gmail.com> | ||
*/ | ||
|
||
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: $argv[0] /path/to/the/project".PHP_EOL; | ||
exit(1); | ||
} | ||
|
||
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?".PHP_EOL; | ||
exit(1); | ||
} | ||
|
||
$sfPackages = array('symfony/symfony' => __DIR__); | ||
foreach (glob(__DIR__.'/src/Symfony/{Bundle,Bridge,Component,Component/Security}/*', GLOB_BRACE | GLOB_ONLYDIR | GLOB_NOSORT) as $dir) { | ||
$sfPackages[json_decode(file_get_contents("$dir/composer.json"))->name] = $dir; | ||
} | ||
|
||
$filesystem = new Filesystem(); | ||
foreach (glob("$argv[1]/vendor/symfony/*", GLOB_ONLYDIR | GLOB_NOSORT) as $dir) { | ||
$package = 'symfony/'.basename($dir); | ||
if (is_link($dir)) { | ||
echo "\"$package\" is already a symlink, skipping.".PHP_EOL; | ||
continue; | ||
} | ||
|
||
if (!isset($sfPackages[$package])) { | ||
continue; | ||
} | ||
|
||
$sfDir = '\\' === DIRECTORY_SEPARATOR ? $sfPackages[$package] : $filesystem->makePathRelative($sfPackages[$package], dirname(realpath($dir))); | ||
|
||
$filesystem->remove($dir); | ||
$filesystem->symlink($sfDir, $dir); | ||
echo "\"$package\" has been linked to \"$sfPackages[$package]\".".PHP_EOL; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
forsymfony/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.
I do as @ro0NL: one repo for dev, never touch directly inside vendor