Skip to main content
Participant
September 28, 2019
Question

Dreamweaver 19.2 color code HTML files as PHP

  • September 28, 2019
  • 3 replies
  • 361 views

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!

    This topic has been closed for replies.

    3 replies

    Nancy OShea
    Community Expert
    Community Expert
    September 28, 2019

    DW uses a Brackets code engine now.  And Brackets code themes are on Gitnub.

    https://brackets-themes.github.io/

     

     

    Nancy O'Shea— Product User & Community Expert
    Legend
    September 28, 2019

    Have a read here too

    Paul-M - Community Expert
    Legend
    September 28, 2019

    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.

    Paul-M - Community Expert
    seippgAuthor
    Participant
    September 29, 2019

    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.)