Skip to content

Commit

Permalink
Merge pull request #593 from emacs-php/feature/php-ini
Browse files Browse the repository at this point in the history
Add php-system-find-php-ini-file and php-ini command
  • Loading branch information
zonuexe authored Nov 26, 2019
2 parents d638cec + 141cf22 commit 09e0a25
Showing 1 changed file with 35 additions and 0 deletions.
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

0 comments on commit 09e0a25

Please sign in to comment.