Skip to content
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

Add php-find-system-php-ini-file and php-ini command #593

Merged
merged 1 commit into from
Nov 26, 2019
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
35 changes: 35 additions & 0 deletions php.el
Original file line number Diff line number Diff line change
Expand Up @@ -413,5 +413,40 @@ When `DOCUMENT-ROOT' is NIL, the document root is obtained from `ROUTER-OR-DIR'.
(if (called-interactively-p 'interactive) #'display-buffer #'get-buffer)
(format "*%s*" buf-name))))

(defun php-ini ()
"Get `php --ini' output buffer."
(interactive)
(let ((buffer (get-buffer-create " *php --ini*")))
(with-current-buffer buffer
(view-mode -1)
(read-only-mode -1)
(erase-buffer)
(shell-command (concat php-executable " --ini") buffer)
(view-mode +1))
(if (called-interactively-p 'interactive)
(pop-to-buffer buffer)
buffer)))

(defun php-find-system-php-ini-file (&optional file)
"Find php.ini FILE by `php --ini'."
(interactive
(list
(let* ((default-directory (expand-file-name "~"))
(buffer (php-ini))
(path (with-current-buffer buffer
(goto-char (point-min))
(save-match-data
(when (re-search-forward ": \\(.+?\\)$" nil nil)
(match-string 1))))))
(when (or (null path) (not (file-directory-p path)))
(when (called-interactively-p 'interactive)
(pop-to-buffer buffer))
(user-error "Failed get path to PHP ini files directory"))
(read-file-name "Find php.ini file: "
(concat (expand-file-name path) "/")
nil nil nil
#'file-exists-p))))
(find-file file))

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