Copy link to clipboard
Copied
Is there a way to color code PHP code inside of HTML files? I've found solutions for older versions of Dreamweaver but it seems they no longer work. Seems like this would be a normal, supported feature.
Thanks!
Copy link to clipboard
Copied
You can create your own theme by duplicating one of the existing ones and then you need to add some custom rules to target PHP code:
The basic rule for colouring all PHP code
.cm-m-clike {
color: #FFC926;
}
add these in addition and play about with the colours to get more specific colouring to your liking:
.cm-m-clike.cm-comment {
color: #CCC;
}
.cm-m-clike.cm-def {
color: #FFC926;
}
.cm-m-clike.cm-variable {
color: #FFC926;
}
.cm-m-clike.cm-variable-2 {
color: #FFC926;
}
.cm-m-clike.cm-variable-3 {
color: #FFC926;
}
You might also want to add a custom color with this tag which colours the actual PHP opening and closing tags (note it will also color the doctype but its the only solutions to my knowledge to date)
.cm-meta {
color: #FFC926;
}
The code editor is an embedded version of Brackets which uses Codemirror at its heart - unfortunately the documentation for Codemirror code colouring is virtually non-existent. You could also look for Bracket code themes which should work in Dreamweaver.
Copy link to clipboard
Copied
Okay, did some googling and found out how to edit the main.less file. I was 'throwing darts' by editing it but I edited both the HTML section and the PHP section like this:
.HTML {
.cm-meta {
color: #C68CFF;
}
.cm-keyword, .cm-builtin {
color: #66D9EF;
}
.cm-variable-2 {
color: #A6E22E;
}
.cm-m-clike {
color: #FFC926;
}
.cm-m-clike.cm-comment {
color: #CCC;
}
.cm-m-clike.cm-def {
color: #FFC926;
}
.cm-m-clike.cm-variable {
color: #FFC926;
}
.cm-m-clike.cm-variable-2 {
color: #FFC926;
}
.cm-m-clike.cm-variable-3 {
color: #FFC926;
}
}
/* PHP Specific Code Colouring */
.PHP {
.cm-meta {
color: #C68CFF;
}
.cm-keyword, .cm-builtin {
color: #66D9EF;
}
.cm-variable-2 {
color: #A6E22E;
}
.cm-m-clike {
color: #FFC926;
}
.cm-m-clike.cm-comment {
color: #CCC;
}
.cm-m-clike.cm-def {
color: #FFC926;
}
.cm-m-clike.cm-variable {
color: #FFC926;
}
.cm-m-clike.cm-variable-2 {
color: #FFC926;
}
.cm-m-clike.cm-variable-3 {
color: #FFC926;
}
}
This succeeded in turning all the PHP including the tags to purple. (The tags are still shown as an error...red circle with an X.)
Copy link to clipboard
Copied
Have a read here too
Copy link to clipboard
Copied
DW uses a Brackets code engine now. And Brackets code themes are on Gitnub.
https://brackets-themes.github.io/