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

[php] Provide html intellisense #670

Closed
ghost opened this issue Nov 25, 2015 · 234 comments
Closed

[php] Provide html intellisense #670

ghost opened this issue Nov 25, 2015 · 234 comments
Assignees
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities languages-basic Basic language support issues php PHP support issues
Milestone

Comments

@ghost
Copy link

ghost commented Nov 25, 2015

In PHP files there is no html tags auto completion, please add.


EDIT 9/13/2018 @egamma: VS Code provides only basic support for PHP, but there are powerful PHP extensions available in the market place:

This feature should be provided by these extensions (Intelephence actually already does support it). Please give these extensions a try and help to make them better by filing issues and pull requests.

This issue has lost focus and turned into a discussion whether VS Code should provide PHP support out of box. However, as with many other language like C#, C++, Go, Python, Rust we do not want to bundle PHP with VS Code but rather rely on our great extension ecosystem. I´m therefore closing this issue.

@Tyriar
Copy link
Member

Tyriar commented Nov 26, 2015

Sounds reasonable. The HTML tag intellisense providers are located here, it might just be a matter of hooking that module up to the PHP code. Also insuring they are only available when outside <?php tags, if I remember how PHP works correctly.

@ghost
Copy link
Author

ghost commented Nov 26, 2015

@Tyriar outside <?php tags means what? Are they availabe when outside <?php ?> tags in PHP files?

@Tyriar
Copy link
Member

Tyriar commented Nov 26, 2015

Outside <?php ?> is HTML, inside is PHP. So the HTML auto complete should only be available outside the <?php ?> tags.

@ghost
Copy link
Author

ghost commented Nov 26, 2015

@Tyriar But now they are not available outside the <?php ?> tags in .php files, maybe they are only available in .html files.

@aeschli aeschli added the feature-request Request for new features or functionality label Nov 27, 2015
@aeschli aeschli changed the title No html tags auto completion [php] Provide html intellisense Nov 27, 2015
@egamma egamma added the languages-basic Basic language support issues label Nov 30, 2015
@osjn
Copy link

osjn commented Dec 7, 2015

Please add this feature quickly, I think it's a basic feature, thank you guys.

@egamma
Copy link
Member

egamma commented Dec 8, 2015

@osjn thanks for helping us with the prioritization by commenting. An even better way to help us would be a Pull Request with an implementation.

@TheColorRed
Copy link

Maybe it is just me, but I think it would be cool if intellisense was available inside of php strings as well.

@frankmuts
Copy link

An upvote from me too. This feature is needed, please.

@Tyriar Tyriar added the help wanted Issues identified as good community contribution opportunities label Mar 9, 2016
@ghost
Copy link
Author

ghost commented Apr 19, 2016

Almost every PHP developer will need this feature in order to pick VSCode as their primary editor.

We need this issue to be fixed in order to target more developers.

Yesterday I tried bumping my head against this problem but unfortunately my lack of TypeScript skills are holding me back to help you on this issue.

@KngHawkon
Copy link

I need this!

@Cocotteseb
Copy link

Same. Simply +1000

@luxzg
Copy link

luxzg commented May 5, 2016

I'm unable to help, but another +1000 from me. HTML/CSS/JS in PHP is common as a mixed file. I've tried full Visual Studio + VS.php - also not supported. I keep wondering why is this overlooked in every Microsoft development tool that supposedly supports PHP. Yes, PHP support is there, but is useless if we don't have IntelliSense (code completition & code suggestions) for HTML/CSS/JS as well.

Same goes for JS blocks & inline CSS in HTML.
If I define in settings.json:
"files.associations": {"*.php": "html"},
... than PHP IntelliSense (obviously) does not work, and HTML kicks in. But inline-CSS by using style=" ...something... "; does not offer any CSS properties when writing in between quotes of style attribute.
Likewise, if I start a <script> block, you won't get IntelliSense for JS, while opening .js file reacts normally.

I do support suggestion that (if it's easier):

  • <?php ... ?> should start the PHP IntelliSense
  • outside <?php ... ?> should start HTML IntelliSense
    but also
  • inside <style> ... </style> and style=" .... " should start CSS IntelliSense
  • inside <script ... > and <script> ... </script> should start JS IntelliSense

Also, if possible, a suggestion by @TheColorRed should be considered, meaning if you are inside
<?php ... ?> but are writing a string eg $string="..." than it should consider turning HTML IntelliSense as well. Thing is, PHP devs often use something like:
<?php
$something="test";
echo "<div><a href="http://sample.com">This is a ".$something."</a></div>";
$continue = "coding here ... etc";
?>
.. to avoid doing blocks with opening/closing php tags all the time, like:
<?php
$something="test"; ?>
<div>
<a href="http://sample.com">This is a <?php echo $something; ?></a>
</div>
<?php
$continue = "coding here ... etc";
?>

Also @egamma , while we don't mean to sound ungrateful or lazy, smug comments don't do much help either, if one of us was competent and knowledgeable enough to code it ourselves - I'm sure we'd do it. Unfortunately - I am not :-/ But if I can help in any other way I'd be glad to (not just by commenting with suggestions, but testing, or whatever).

I hope that there IS a consensus that this feature should exist, and that current PHP support without it is only a partial support for the most PHP devs.

P.S. And again, not to sound as a critic - I really like VS Code so far, and am most thankful to everyone that contributed and keep contributing to this wonderful project!

EDIT:
Would simply including/referencing one .ts file to another work?
E.g. in /languages/php/common/php.ts
include: /languages/html/common/html.ts
include: /languages/css/common/css.ts
include: ...

While there could be some overlap with the tag/attribute/function names nothing comes to my mind at the moment... And for IntelliSense it's non-issue I think as each would have different icon, only color coding could be messed in such cases... Am I missing something else?

@Zeanix
Copy link

Zeanix commented May 17, 2016

if this is not getting added, then i have to switch editor, right now i use 2 editors...

@mrqtsfr
Copy link

mrqtsfr commented May 17, 2016

Please, how can I deactivate de HTML IntelliSense when I'm working with a PHP?

This option is a nightmare, because I can't tab in a variable because automatically create a XML/HTML tag.

I don't mix my PHP code with the HTML, and I will not make this error ever, please, at least add the option to deactivate it in PHP "mode".

@TheColorRed
Copy link

TheColorRed commented May 17, 2016

For PHP you should try crane intellisense https://marketplace.visualstudio.com/items?itemName=HvyIndustries.crane

@FieldMarshallVague
Copy link

@TheColorRed Crane Intellisense has the problem. It's by far the most popular VS Code PHP extension, so I guess this is what most people are reporting their problem with.

@thanhhungtn1
Copy link

I've just tried vscode but lacking of this feature just stop me using this IDE. Please provide this feature as it a must have feature for every IDE.
Thank you in advanced.

@stevemk14ebr
Copy link

This is very needed. It's incredibly annoying not getting proper intellisense when putting either php code inside a html file, or putting html in a php file.

@ARehmanMahi
Copy link

@SharakPL explain? Read the 3 year old DEAD thread, It will explain to you it ain't gonna happen.

@benyaminl
Copy link

@bsienn It's there with emnet, html on php is using emnet, try to learn it.. https://docs.emmet.io/ please... it's working anyway...

@SharakPL
Copy link
Contributor

SharakPL commented Jun 14, 2018

@bsienn explain me this then: why you giving up should be a reason to close this issue?

@benyaminl emmet is fine, but it only works when I create new tags. It's useless when I need to edit tags i.e. add some attributes to a link, because there's still no intellisense for html in php files

@benyaminl
Copy link

benyaminl commented Jun 14, 2018 via email

@caryevans
Copy link

I am trying to convert from using Brackets.io to VS Code since I've read so many great things about Intellisense. This basic feature is preventing me. It scares me that it goes back for 3 years and nothing has been done.

Does anyone know if there is a plug-in or a way to register .php files to use .html auto-complete?

thanks for your help.

@brunogc
Copy link

brunogc commented Jul 12, 2018

Any news on this issue?
I believe that just doing the same implementation made for mixed editing in html files, where html + css + js works fine.

Another alternative is to implement in the Extension API a way to watch the file excerpt and change the selected language.

@RiFi2k
Copy link

RiFi2k commented Jul 24, 2018

I made this because I was annoyed at nested HTML in PHP, this should format based on whatever native settings you have for html.format and editor format on save/type Format HTML in PHP.

Also I get full auto-complete, intellisense doing it this way.

@BxDev
Copy link

BxDev commented Jul 24, 2018

@RiFi2k Hi! I try install your extension, but for me is nothing changes. In description is set the nothing to do for this extension to by work.

@RiFi2k
Copy link

RiFi2k commented Jul 24, 2018

@BxDev Hey! So you would need to have
html.format.enable = true
editor.formatOnSave = true
and any other settings in vscode related to html formatting or editor formatting you might want, set up.

Then it wants to format nested HTML in .php files, so you also need to make sure you have a .php file with some code like this:

<?php
$hi = true;

?>
<div class="correct-formatting">
                                     <div class="wrong-formatting">
</div>
</div>

When you save it should fix the HTML div's

If your still having issues, let me know I'll help you get it rolling.

@BxDev
Copy link

BxDev commented Jul 24, 2018

@RiFi2k thanks for the replies!
I write this in user setting:
"html.format.enable": true, "editor.formatOnSave": true
After, I create a php file whit your example, but it don't work :-(
l213wgru87dzrr

@RiFi2k
Copy link

RiFi2k commented Jul 24, 2018

@BxDev Actually it looks as though it did it's job perfectly

<?php
$hi = true;

?>
<div class="correct-formatting">
                                     <div class="wrong-formatting">
</div>
</div>

to

<?php
$hi = true;

?>
<div class="correct-formatting">
        <div class="wrong-formatting">
        </div>
</div>

That is all it does, hopefully you weren't confused about functionality

@BxDev
Copy link

BxDev commented Jul 24, 2018

@RiFi2k ohh yeea :) I got it :) Sorry about that. But for me, very important, is highlight pair tag in mixed php/html/js/css documents. Thanks for your work!

@TheDutchCoder
Copy link

TheDutchCoder commented Aug 13, 2018

This is a 3 year old issue and it will never get resolved is my feeling.
This is such a basic thing to have in an editor and it's making my day-to-day work incredibly annoying.

I'll probably have to switch back to ST3, because I feel like VScode, especially lately, has been moving backwards by adding all kinds of fancy features but ignoring their core problems.

@steebchen
Copy link

@TheDutchCoder It's because nobody wants to code PHP these days, which is the right thing to do. :D

@benyaminl
Copy link

@steebcheen please keep on the topic. Thanks

@benyaminl
Copy link

benyaminl commented Aug 18, 2018

@Tyriar Anyway does anyone have been assigned for this? Or it's not?
EDIT: Oh It's assigned.. Okay

@thanasisHS
Copy link

thanasisHS commented Aug 30, 2018

@RiFi2k Hello and thanks for trying to help! I tried your extension but it doesn't work. I tried the settings that you provided, but still no dice. Maybe it depends on the php formatter in use? What extension do you suggest to use to enable php formatting in the first place?

OK, quick update: It works on save, which is great! It doesn't work with the right click context menu. I guess it's a fair compromise :)

@ThemeCSS
Copy link

ThemeCSS commented Sep 12, 2018

I thought the issue is only in my preference. When I mixed the HTML code to php the format is really messy like when I hit tab it will tab size to 4 and then add a new one now tab size is 2. I'd like to switch from ST3 to VSC but this stops me from switching to VSC. I guess I have to stay on ST3 for now.

@RiFi2k
Copy link

RiFi2k commented Sep 12, 2018

@thanasisHS Sorry just saw this.

My extension will only run if format on save is configured, and it doesn't run as an actual PHP formatter, runs onBeforeSave.

I pretty much published my whole config as a few gists, feel free it took me months of work to get it perfect. For formatting I use PHPCBF but use this one, I know it only has 300 installs but he updated and merged the code from all the dead phpcbf extensions, it's money.
https://marketplace.visualstudio.com/items?itemName=ValeryanM.vscode-phpcbf

Here are my gists, if anyone else is interested too in my config. It does php, js, scss, css, vue - auto formatting and linting with eslint, stylelint, phpcbf, phpcs, prettier. It's a beat once you get it all set up.

Global
https://gist.github.com/RiFi2k/d43e84788b1798252f30cac28b6f6eda

Project
https://gist.github.com/RiFi2k/42e294f3785bdbbc2641c4b18955e16f

All the dotfiles, composer.json, package.json, php ruleset
https://gist.github.com/RiFi2k/8b753d1f12a36760f3ee6e1322daf708

@egamma
Copy link
Member

egamma commented Sep 13, 2018

Closing this issue. I´ve explained the reason in the description of the issue above.

@egamma egamma closed this as completed Sep 13, 2018
@jens1o
Copy link
Contributor

jens1o commented Sep 13, 2018

thanks. Code is getting more ruined each day. I thought you at Microsoft were cool with all this FOSS-initative, but it is still not independent, but focused to make money by advertising Github and Azure.

@egamma
Copy link
Member

egamma commented Sep 13, 2018

@jens1o I´m confused, this decision is all about fostering the OSS ecosystem. The referenced extensions are OSS projects, please help to make them better. The resources of the VS Code team are not unlimited.

Also, please do not forget our Code of Conduct and let´s communicate in a respectful way.

@jens1o
Copy link
Contributor

jens1o commented Sep 13, 2018

I just don't understand why you prioritize tasks over other, although the community definitely wants those. I only hear "issue reduction" and "out of scope", and, oh yeah, "limited resources"(that's why the community is here, lol). Nobody complains about things not coming soon, but a little bit more focus on the needs of the community would definitely help. Why do we need to keep the issue number low, even though they don't pollute anything? In my eyes, the Code roadmap passed the sweet spot 2 iterations ago. Now, it is all about earning money(with the big community earned throughout the years; I'm using it since the first demo of Build(); everyday) by integrating paid and third-party products(like GitHub, owned by Microsoft).

I'm saying that I'm not feeling welcome in this community anymore(and I'm honestly disappointed), I don't attack you personal in any way, so there is no reason to reference the COC here. It is part of FOSS-software to have open discussions.

But speaking of COC, I'd quote this:

Understand disagreements

I don't get why you want to shut me down, only because I disagree with the politics you do.

I'm trying to understand why you changed your politics, so could you please elaborate?

@popcorner
Copy link

@egamma I don't think that your reason for closing this issue is reasonable. I understand that visual studio code can't and shouldn't provide all the features out of the box, but HTML support for PHP language should be one of the most basic feature for a PHP editor. Maybe most of the features for PHP should be provided by extensions, but this one shouldn't. Lots of editors have this feature, even the simple text editor, Notepad++, have this feature. This is part of the basic PHP grammar, and you can't write PHP without it. An editor shouldn't say that it supports PHP without this feature, for it can't read PHP in the right way.

And why does Javascript in HTML file works well and CSS in HTML works well without any extension in vscode? It seems that vscode have this feature but don't want to make a similar one for PHP, That's unfair.

This feature is really important for PHP users, and most user won't try to search these issues and they know nothing about the extensions which can help them get these basic and necessary features. These users may simply download this editor, install it and find this "bug", then uninstall it immediately and get a very bad impression about vscode. They won't say anything here. All the users who want to share their opinions here are the people who really want vscode to be better. The feeling for writing PHP code without this funtion is really too painful, you can't tell the blocks apart, you have to count the html tags manually, or convert the file format from php to html, and from html to php many times. All the other languages I have ever tried on the vscode won't have such bad feelings without any extension installed. Users won't know the reason, they just care about the user experience. Please consider about this and do something, even adding a little bit highlight is good too:

  • provide some basic support for HTML, or
  • provide an official extension with this feature and install automatically when using PHP
  • or even a simple recommedation for all the PHP user and install the recommended extension with one click, then get this feature and make vscode be able to really support PHP

@RiFi2k
Copy link

RiFi2k commented Sep 13, 2018

Agreed, @popcorner is correct this is essential for PHP devs and considering WordPress powers ~30% of the internet or more and pretty much every theme or plugin has PHP nested with HTML in every template file. So basically a ridiculous amount of users right there in need of this.

Now I actually think the core of this whole issue lies with the fact you can not register multiple formatting extensions at the same time. There is basically kind of a race on that hook and only one can win, plus you can't see as a user what is trying to run when, and which one actually ran. So for a PHP file, odiously your going to go with a formatting extension that does PHP code over HTML. But if you could chain formatting extensions and there was a hook order or something that was changeable then you could register a PHP and an HTML and then set the priority / order for one to run first / last. For example this whole issue is fixed if you can...

Step One run PHPCBF or similar PHP formatting extension.
Step Two run js-beautify html formatting which just skips over all the PHP anyways and does the HTML only, which is the exact same thing I do in my extension, Format HTML in PHP, to fix the problem. But I have to run it onBeforeSave instead of using the default formatting registration, but this shouldn't have to be the solution.

So to sum it up, it's very needed, but instead of fixing / not fixing the issue, why not explore my idea above and then you end up having a way better experience with every language and formatting, for users and extension developers.

@vscodebot vscodebot bot locked and limited conversation to collaborators Oct 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities languages-basic Basic language support issues php PHP support issues
Projects
None yet
Development

No branches or pull requests