How I can turn on highilighting php code in org-mode structure block?

enter image description here

  • I can't find ob-php anywhere. I think it is not supported in babel org-mode. Nov 6, 2018 at 22:08
  • 1
    https://github.com/stardiviner/ob-php I just copy paste ob-php.el into my init.el so I can execute php code. The author of ob-php wrote 'I put it in Org-mode contrib/ now.' but I couldn't find it int org-mode files. Any ideas how highlighting can be done? Maybe from other packages?
    – slk500
    Nov 6, 2018 at 22:20
  • Maybe it's been added to a new version of org-mode that isn't bundled with any version of Emacs yet.
    – user12563
    Nov 8, 2018 at 20:15
  • You need to add opening tag <?php for syntax highlighting to work
    – Paul Elms
    Oct 4 at 10:30

2 Answers 2


ob-php is now in Org mode contrib and available through the org-plus-contrib package in Org ELPA.

You can install this package by adding Org ELPA to your package-archives list in your init file:

(require 'package)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)

Then you can install the org-plus-contrib package by opening the package manager (M-x list-packages), locate the package (C-s org-plus-contrib RET), mark it for installation (i), and finally actually install it (x). (It'd be nice if the package module offered an install-package command but until it does, you'll have to go through this process.)

If you don't want all of contrib, then you'll have to grab ob-php directly from the Org mode Git repository (direct link) and load it yourself from your init file.

  • It should be noted that with the latest version of Org mode, ob-php breaks due to a recursive require of org on line 17 of ob-php.el. This line should be commented out and the compiled ob-php.elc file removed in order to get things working again. Jan 16, 2019 at 15:18
  • 1
    Going forward it appears that ob-php will be removed from the new org-contrib ELPA package after Org 9.5 is released. Aug 16, 2021 at 18:52

With the current versions of php-mode and org-mode, PHP syntax highlighting in org code blocks happens by default.

The version of org-mode in Emacs 26.1 includes this support. For earlier versions of Emacs you can install a newer version of org-mode from its ELPA repository.

So if you have at least Emacs 26.1 for php highlighting in org-mode you need to just install php-mode.

  • Your answer isn't complete. Can you add the entire solution to your problem?
    – user12563
    Nov 8, 2018 at 20:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.