PHP syntax not being highlighted


#1

So for some reason my PHP syntax is not being highlighted and I can’t figure out why :frowning: It’s rather annoying and makes the code a little harder to read.

I’m using the atom dark theme.

Here’s my installed packages:

and here’s an example:

any help would be greatly appreciated :smile:
Regards,
Austen


#2

It looks like the HTML in the screenshot is being highlighted, is the file being recognized as PHP? Can you include a minimum repro (as text please)?


#3

Yea I’d venture a guess that the file has an .html extension, instead of .php.
Would be good to see if the highlighting changes with the extension.


#4

The bottom of the editor mentions the grammar:

It’s CoffeeScript in my case, if that says HTML in your case, then you know what’s wrong. You can click it or you can do ctrl-shift-L.


#5

I am having the same issue. The file extension is .php but I have an HTML Doctype/Skeleton setup, So it looks like the syntax detection is of higher priority than the the extension type. I ended up using the file-types package and added the following to my config.cson

  "file-types":
    php: "text.html.php"

But I do feel that this is something that should be built in.


#6

Getting the same issue. Version 0.192.0 (0.192.0)

/Users/fjs/.atom/packages (13)
β”œβ”€β”€ Remote-FTP@0.6.2
β”œβ”€β”€ atom-beautify@0.23.4
β”œβ”€β”€ atom-htmlizer@0.1.1
β”œβ”€β”€ autoclose-html@0.15.0
β”œβ”€β”€ autocomplete-css@0.6.0
β”œβ”€β”€ autocomplete-plus@2.9.0
β”œβ”€β”€ autoprefixer@2.2.1
β”œβ”€β”€ color-picker@1.6.0
β”œβ”€β”€ file-types@0.3.0
β”œβ”€β”€ highlight-line@0.10.1
β”œβ”€β”€ mobile-preview@0.4.0
β”œβ”€β”€ open-in-browser@0.4.3
└── robin-language-php@0.9.0


#7

@fseminario, could you give the following information?

  • What OS and version are you running?
  • Can you reproduce the issue after completely exiting Atom and restarting using atom --safe?

Also, can you supply a minimum repro?


#8

I am running Mac OS X 10.10.2

Running atom --safe did not change anything.

Not sure what you mean by, β€œβ€¦supply a minimum repro?”


#9

What is the smallest chunk of text that will show the issue? I suspect that what you’re running into is a case of this:

If all you had in your file was:

<?php get_footer(); ?>

Would it show the issue? Because the short version highlights in mine:

Granted, it isn’t very colorful, but perhaps that is just my theme.


#10

Tried creating an empty file and just including <?php get_header(); ?> but that didn’t work either.


#11

What syntax theme are you using?


#12

Looks like you’re not using the official php language grammar but an unofficial one: robin-language-php@0.9.0

Have you tried disabling this package to use the core one instead?


#13

@abe Yeah that was one I added to test if it would fix it but it didnt. I have since removed it.

Current Packages:

/Users/fjs/.atom/packages (9)
β”œβ”€β”€ Remote-FTP@0.6.2
β”œβ”€β”€ atom-beautify@0.23.4
β”œβ”€β”€ atom-htmlizer@0.1.1
β”œβ”€β”€ autoclose-html@0.15.0
β”œβ”€β”€ autocomplete-css@0.6.0
β”œβ”€β”€ autocomplete-plus@2.9.0
β”œβ”€β”€ autoprefixer@2.2.1
β”œβ”€β”€ color-picker@1.6.0
└── highlight-line@0.10.1

@leedohm my syntax theme Atom Dark / Atom Dark


#14

Confirmed that the specific code you show is monochromatic on Atom Dark, but if you take off the (); it shows in different colors. If you can confirm the same behavior, it is a theme issue. Try the One Dark syntax theme, the specific code you show should render in a more colorful way.


#15

@leedohm yep! it is a theme issue


#16

I moved 4 posts to a new topic: Intermittent PHP syntax highlighting issue


#18

i tried many themes but php code is not highlighting like what I see in sublime. Its difficult to read. Can anyone help me with that.


#19

changed the language to php using Ctrl+Shift+L in windows :slight_smile:


#20

Did you add <?php at the beginning of your document?