Skip to content

Impl php-phpdbg-disassemble-file and php-parse-file #804

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions lisp/php.el
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@
:tag "PHP Executable"
:type 'string)

(defcustom php-phpdbg-executable (list "phpdbg")
"The location of the PHPDBG executable."
:group 'php
:tag "PHP PHPDBG Executable"
:type '(repeat string))

(defcustom php-php-parse-executabe nil
"The location of the php-parse executable."
:group 'php
:tag "PHP php-parse Executable"
:type '(repeat string))

(defcustom php-site-url "https://www.php.net/"
"Default PHP.net site URL.

Expand Down Expand Up @@ -804,5 +816,29 @@ When `DOCUMENT-ROOT' is NIL, the document root is obtained from `ROUTER-OR-DIR'.
#'file-exists-p))))
(find-file file))


(defun php-phpdbg-disassemble-file (file)
"Read PHP FILE and print opcodes."
(interactive (list (if (or buffer-file-name (zerop (prefix-numeric-value current-prefix-arg)))
buffer-file-name
(expand-file-name
(read-file-name "Select PHP file: " default-directory buffer-file-name)))))
(let ((args `(,@php-phpdbg-executable "-dopcache.enable_cli=1" "-p*" ,file)))
(compile (mapconcat #'shell-quote-argument args " "))))

(defun php-parse-file (file)
"Parse PHP FILE and print node tree."
(interactive (list (if (or buffer-file-name (zerop (prefix-numeric-value current-prefix-arg)))
buffer-file-name
(expand-file-name
(read-file-name "Select PHP file: " default-directory buffer-file-name)))))
(let* ((project-dir (php-project-get-root-dir))
(executable (or php-php-parse-executabe
(file-executable-p (expand-file-name "vendor/bin/php-parse" project-dir))
(executable-find "php-parse")
(user-error "`php-parse' command not found")))
(args `(,@(if (listp executable) executable (list executable)) ,file)))
(compile (mapconcat #'shell-quote-argument args " "))))

(provide 'php)
;;; php.el ends here
Loading