Skip to content

Commit 09e0a25

Browse files
authored
Merge pull request #593 from emacs-php/feature/php-ini
Add php-system-find-php-ini-file and php-ini command
2 parents d638cec + 141cf22 commit 09e0a25

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

php.el

+35
Original file line numberDiff line numberDiff line change
@@ -413,5 +413,40 @@ When `DOCUMENT-ROOT' is NIL, the document root is obtained from `ROUTER-OR-DIR'.
413413
(if (called-interactively-p 'interactive) #'display-buffer #'get-buffer)
414414
(format "*%s*" buf-name))))
415415

416+
(defun php-ini ()
417+
"Get `php --ini' output buffer."
418+
(interactive)
419+
(let ((buffer (get-buffer-create " *php --ini*")))
420+
(with-current-buffer buffer
421+
(view-mode -1)
422+
(read-only-mode -1)
423+
(erase-buffer)
424+
(shell-command (concat php-executable " --ini") buffer)
425+
(view-mode +1))
426+
(if (called-interactively-p 'interactive)
427+
(pop-to-buffer buffer)
428+
buffer)))
429+
430+
(defun php-find-system-php-ini-file (&optional file)
431+
"Find php.ini FILE by `php --ini'."
432+
(interactive
433+
(list
434+
(let* ((default-directory (expand-file-name "~"))
435+
(buffer (php-ini))
436+
(path (with-current-buffer buffer
437+
(goto-char (point-min))
438+
(save-match-data
439+
(when (re-search-forward ": \\(.+?\\)$" nil nil)
440+
(match-string 1))))))
441+
(when (or (null path) (not (file-directory-p path)))
442+
(when (called-interactively-p 'interactive)
443+
(pop-to-buffer buffer))
444+
(user-error "Failed get path to PHP ini files directory"))
445+
(read-file-name "Find php.ini file: "
446+
(concat (expand-file-name path) "/")
447+
nil nil nil
448+
#'file-exists-p))))
449+
(find-file file))
450+
416451
(provide 'php)
417452
;;; php.el ends here

0 commit comments

Comments
 (0)