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. – manandearth Nov 6 '18 at 22:08
  • 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 '18 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 '18 at 20:15

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. – Chris Charabaruk Jan 16 '19 at 15:18

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 '18 at 20:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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