How I can turn on highilighting php code in org-mode structure block?
2 Answers
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 ofob-php.el
. This line should be commented out and the compiledob-php.elc
file removed in order to get things working again. Commented Jan 16, 2019 at 15:18 -
1Going forward it appears that ob-php will be removed from the new org-contrib ELPA package after Org 9.5 is released. Commented 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?– user12563Commented Nov 8, 2018 at 20:16
org-mode
that isn't bundled with any version of Emacs yet.<?php
for syntax highlighting to work