Skip to content
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

Open Files in IDE in a container or in a virtual machine #175

Closed
vv12131415 opened this issue Dec 8, 2016 · 6 comments
Closed

Open Files in IDE in a container or in a virtual machine #175

vv12131415 opened this issue Dec 8, 2016 · 6 comments
Assignees
Labels
type:docs Documentation
Milestone

Comments

@vv12131415
Copy link

Working on VM (vagrant) and want to open files in PHPstorm on my host machine. But I can't because path is not right.
Guys from symfony made it in their framework docs at the end of ide section

@dynasource
Copy link
Member

@vv12131415
Copy link
Author

vv12131415 commented Dec 8, 2016

@dynasource Yes, of course. The difference is that I need some thing like this
'traceLine' => '<a href="phpstorm://open?url={file}&line={line}&/path/to/guest/>/path/to/host/">{file}:{line}</a>',
so I use yii2-advanced with vagrant and my and if I enable traceLine like this I will get link to

phpstorm://open?url=/app/backend/controllers/EventController.php&line=64 but its a path to my guest (vagrant) and but I want it to bee like this (my actual, host machine path)
phpstorm://open?url=/home/vlady/projects/someapp/backend/controllers/EventController.php&line=64

@dynasource
Copy link
Member

have you tried using the callback https://github.com/yiisoft/yii2-debug/blob/master/Panel.php#L134

@vv12131415
Copy link
Author

@dynasource No because don't know how to use it properly

@samdark samdark added the type:docs Documentation label Dec 9, 2016
@francislavoie
Copy link
Contributor

francislavoie commented Sep 5, 2017

So, I want to do this with Sublime Text, and I have the same problem - I run my code in docker, and the path to the app is different within the container than outside it. Would be great if there was a base path option, defaulting to just whatever the app sees, and overridable by a string in the module config.

I'm pretty sure this is more than just a documentation task, I think the module itself should have a new property, something like $debugBasePath (cause there's already basePath inherited) which is default null (meaning whatever the filesystem path is) and overridable by something like /home/myname/myapp

Something like this, in getTraceLine():

if($this->module->debugBasePath && is_string($this->module->debugBasePath)) {
    $options['file'] = str_replace(Yii::$app->basePath, $this->module->debugBasePath, $options['file']);
}

And in my config, something like this:

[
    'class' => 'yii\debug\Module',
    'traceLine' => '<a href="subl://{file}:{line}">{text}</a>',
    'debugBasePath' => '/home/myname/myapp',
]

... I guess I could toss together a PR, I'm already half-way there in implementing it 😆

@francislavoie
Copy link
Contributor

Apparently, according to #267 (comment), you can do the following instead of my proposed PR:

        'traceLine' => function($options, $panel) {
            $filePath = str_replace(Yii::$app->basePath, '/home/myname/myapp', $options['file']);
            return strtr('<a href="subl://{file}:{line}">{text}</a>', ['{file}' => $filePath]);
        },

This should probably be documented.

francislavoie added a commit to francislavoie/yii2-debug that referenced this issue Sep 6, 2017
@samdark samdark added this to the 2.0.12 milestone Sep 6, 2017
@samdark samdark self-assigned this Sep 6, 2017
@samdark samdark modified the milestones: 2.0.12, 2.0.13 Oct 9, 2017
@samdark samdark closed this as completed in cfdd6f0 Oct 9, 2017
@samdark samdark modified the milestones: 2.0.13, 2.0.12 Oct 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:docs Documentation
Projects
None yet
Development

No branches or pull requests

4 participants