Missing PHP syntax highlighting support in devtools' CodeMirror instance

25 views
Skip to first unread message

Fehmi Özüseven

unread,
Nov 21, 2022, 4:38:35 PM11/21/22
to Chromium-discuss
Chrome Version : 107.0.5304.110 (Official Build) (x86_64)
OS : macOS Version 11.6.7 (Build 20G630)

What steps will reproduce the problem?
— Add a folder that contains a PHP file to the Workspace in Sources tab
- Click to the PHP file to see its content

What is the expected result?
The content of the PHP file should have syntax highlighting like JS, HTML, XML, JSON and python files. The dependencies are already loaded but not used:
https://github.com/ChromeDevTools/devtools-frontend/blob/main/front_end/third_party/codemirror.next/package.json#L16

I think there is a mime-type issue:
https://github.com/ChromeDevTools/devtools-frontend/blob/main/front_end/ui/components/code_highlighter/CodeHighlighter.ts#L122

The mime type of the file is "text/x-php" because the file is in a Workspace and served via operating system, not a server. I think the mime should be "text/x-php" not "application/x-httpd-php".

// Begin Terminal
file --mime-type test.php: text/x-php
// End Terminal

What happens instead?
The content shows in the editor, but no syntax highlighting and any PHP language support. Please see the attachment.

PS:
Maybe you can add alternative mime types to CodeHighlighter.ts, just like you did for JS files. I'm not sure if it will be enough to solve, though, but I just wanted to share it as an idea.

What do you think? I tried to open an issue with above content on Issues - chromium but looks like there are a lot of spams in there, so I was afraid nobody will see it, so I decided to add here too.
php.jpg

Jon Perryman

unread,
Nov 21, 2022, 5:03:43 PM11/21/22
to woeb...@gmail.com, Chromium-discuss
PHP is a server language and has nothing to do with the browser. It does not make sense to add functionality that is not providing anything useful to web browser debugging. If you want to get any consideration, you will need to add justification why developers will use it when this is in their IDE. I wouldn't hold out any hope for this feature.

--
--
Chromium Discussion mailing list: chromium...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-discuss

---
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-discu...@chromium.org.
Reply all
Reply to author
Forward
0 new messages