From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Vincenzo Pupillo Newsgroups: gmane.emacs.bugs Subject: bug#72966: 30.0.90; [PATCH] php-ts-mode: custom php.ini config for the built-in php webserver Date: Mon, 02 Sep 2024 15:29:23 +0200 Message-ID: <5614567.rdbgypaU67@fedora> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart3491391.LZWGnKmheA" Content-Transfer-Encoding: 7Bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36648"; mail-complaints-to="usenet@ciao.gmane.io" To: 72966@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 02 15:40:39 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sl7IN-0009KK-7b for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 02 Sep 2024 15:40:39 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sl7Ho-0007Df-0Z; Mon, 02 Sep 2024 09:40:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sl7Hm-00078D-BD for bug-gnu-emacs@gnu.org; Mon, 02 Sep 2024 09:40:02 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sl7Hm-0000Bj-1t for bug-gnu-emacs@gnu.org; Mon, 02 Sep 2024 09:40:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=wJxog3eEWZk1k9EePpncv1xsCxU3zpH73Lea8z3A1CE=; b=WL1bKfAByCpofYcWbGNfmi1g43JHrN8qngkv5kzELFyt65ZAGIbHvGtiUdQea69jWfDSxYsm59rEzDY5OyyibpEHCu4bURFffm1gk9VsEy9VJVnCzYisdKwNeHOiXTFDEoyXOJplK5TzCYrbltYwH3w76myeKcVb0hnRWHMOVUdkzxm4HHqDsu7V1P1143Wj6WTfBEvB8XFEkarJdETeu6LFOsK9MEzxan3+6U3vZeHF2xebpE66ClmKMA+yicuWztD0pteEHsKax2DRpDavKdckCcDIhllK34BaHnmqVSndVOy+qJFgbA8u9mxkXlgpnWINBEQffT5HR0uW+Rv2zw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sl7Ik-00058I-My for bug-gnu-emacs@gnu.org; Mon, 02 Sep 2024 09:41:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Vincenzo Pupillo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 02 Sep 2024 13:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 72966 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: Bug Emacs Original-Received: via spool by submit@debbugs.gnu.org id=B.172528440919541 (code B ref -1); Mon, 02 Sep 2024 13:41:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 2 Sep 2024 13:40:09 +0000 Original-Received: from localhost ([127.0.0.1]:48728 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sl7Ht-000554-2S for submit@debbugs.gnu.org; Mon, 02 Sep 2024 09:40:09 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:41682) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sl78r-0004fT-2Z for submit@debbugs.gnu.org; Mon, 02 Sep 2024 09:30:50 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sl77r-0004lR-He for bug-gnu-emacs@gnu.org; Mon, 02 Sep 2024 09:29:47 -0400 Original-Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sl77c-0007Na-Ax for bug-gnu-emacs@gnu.org; Mon, 02 Sep 2024 09:29:47 -0400 Original-Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2f4f24263acso63345601fa.0 for ; Mon, 02 Sep 2024 06:29:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725283765; x=1725888565; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=wJxog3eEWZk1k9EePpncv1xsCxU3zpH73Lea8z3A1CE=; b=EMz8LmCpT66Yu15bs0E57haGRdpgOVvFb3gr17NMD9HVBO8Ej3NycRkpdvEaWt8pRO SC2N0PFg0rebTbZayO+k3M4YxGeLLEjj5fq/AueFREaLmlUVAG5b2pikgPdnMt9K2Whe KFxRllLFQXjR1LHTrEFuFtVIy5mABTtj357Q9Bm5KsGa01Mu7cdUUjk+jerGdkwf6zEK qt+4OpwlQG+1Uk1sw/LOeWpJS6GfV1d9JkG7iTZd/9DdY9eb6uNJl0Dr8y7DkdUJIb+/ A3j+oAwiQbVS7pk5rQ9IGt3oZ3cgG0seDOvqjawIjq9PTVrhRSLZqVTuuGqsWSGq1bCc 3dPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725283765; x=1725888565; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wJxog3eEWZk1k9EePpncv1xsCxU3zpH73Lea8z3A1CE=; b=h+irF7EZt4t1nAxlPJnXKd1bi9vxS2YMfNIfWLEJXgqLWoJpl+L7qjedjftPcCPwsR 1mFWzdmtIDkuhTASIfH6WSo7LaHChMS9QgcfleRbNRSt5ynZOu0KWkYE6Pl7BNike954 BhA3qbQ20iY/gMPZAUMPZSgYcAFNw60bNKyRZ8Oy8GdXaMG35K0KRCUX9MduK+CR10gD 4VTIyumZZTOZnWKYKR/kBxHsiAF4nBhxJOceGwNM5TcOVIDHm7Ac1c1sqUAvfNW0j6Jv mwudC3ap6uiKzOlZNqnktqEJ+88r1FodBeLVmgws6+26i+uaT1w74hmc8gMyOEHoD7Pr oKbw== X-Gm-Message-State: AOJu0YwqpfGREJEo9OwxwH6f4qckUk3I9nQrGb6XqJqJIr32PrkNhm9V YKWL9bz2lyXHAEOGOMn+v53A3xKijZgChkotkvN76VgLYJe92yb78+rrbg== X-Google-Smtp-Source: AGHT+IFApJM5XUXN8yJ4KSZQmHYpmPHEr81Z0TSJ9vnz+fYPi9oihXtepSebyGg4zxWoDd2bwVmwiA== X-Received: by 2002:a2e:be03:0:b0:2f4:f253:ec7 with SMTP id 38308e7fff4ca-2f6104270b5mr130397211fa.0.1725283764398; Mon, 02 Sep 2024 06:29:24 -0700 (PDT) Original-Received: from fedora.localnet (2-230-139-124.ip202.fastwebnet.it. [2.230.139.124]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a8989022ac4sm560460366b.59.2024.09.02.06.29.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Sep 2024 06:29:24 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::230; envelope-from=v.pupillo@gmail.com; helo=mail-lj1-x230.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:291107 Archived-At: This is a multi-part message in MIME format. --nextPart3491391.LZWGnKmheA Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" Ciao, this patch adds a new CONFIG attribute to 'php-ts-mode-run-php-webserver' that allows you to specify an alternative php.ini file to the default (or whatever is specified in 'php-ts-mode-php-config'). Thanks. Vincenzo. --nextPart3491391.LZWGnKmheA Content-Disposition: attachment; filename="0001-Support-for-custom-php.ini-for-the-built-in-PHP-web-.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0001-Support-for-custom-php.ini-for-the-built-in-PHP-web-.patch" >From 8b688884219e081a086559728251172d710b51e2 Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo Date: Mon, 2 Sep 2024 14:11:01 +0200 Subject: [PATCH] Support for custom php.ini for the built-in PHP web server. A new CONFIG attribute, which defaults to 'php-ts-mode-php-config', allows an alternative php.ini file to be specified for the built-in web server. The 'php-ts-mode-run-php-webserver' function, when called interactively with a prefix argument, also requires this new attribute. * lisp/progmodes/php-ts-mode.el (php-ts-mode-run-php-webserver): New CONFIG attribute. Update docstring. * lisp/progmodes/php-ts-mode.el (php-ts-mode--webserver-read-args): Support the new TYPE. Update docstring. --- lisp/progmodes/php-ts-mode.el | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/lisp/progmodes/php-ts-mode.el b/lisp/progmodes/php-ts-mode.el index 3f89de14075..34304049c5c 100644 --- a/lisp/progmodes/php-ts-mode.el +++ b/lisp/progmodes/php-ts-mode.el @@ -1469,8 +1469,12 @@ php-ts-mode ;;;###autoload -(defun php-ts-mode-run-php-webserver (&optional port hostname document-root - router-script num-of-workers) +(defun php-ts-mode-run-php-webserver (&optional port + hostname + document-root + router-script + config + num-of-workers) "Run PHP built-in web server. PORT: Port number of built-in web server, default `php-ts-mode-ws-port'. @@ -1482,12 +1486,14 @@ php-ts-mode-run-php-webserver Prompt for the document-root if the default value is nil. ROUTER-SCRIPT: Path of the router PHP script, see `https://www.php.net/manual/en/features.commandline.webserver.php' +CONFIG: Alternative php.ini config, default `php-ts-mode-php-config'. NUM-OF-WORKERS: Before run the web server set the PHP_CLI_SERVER_WORKERS env variable useful for testing code against multiple simultaneous requests. + Interactively, when invoked with prefix argument, always prompt -for PORT, HOSTNAME, DOCUMENT-ROOT and ROUTER-SCRIPT." +for PORT, HOSTNAME, DOCUMENT-ROOT, ROUTER-SCRIPT and CONFIG." (interactive (when current-prefix-arg (php-ts-mode--webserver-read-args))) (let* ((port (or @@ -1502,6 +1508,9 @@ php-ts-mode-run-php-webserver document-root php-ts-mode-ws-document-root (php-ts-mode--webserver-read-args 'document-root))) + (config (or config + (when php-ts-mode-php-config + (expand-file-name php-ts-mode-php-config)))) (host (format "%s:%d" hostname port)) (name (format "PHP web server on: %s" host)) (buf-name (format "*%s*" name)) @@ -1509,6 +1518,8 @@ php-ts-mode-run-php-webserver nil (list "-S" host "-t" document-root + (when config + (format "-c %s" config)) router-script))) (process-environment (cons (cond @@ -1529,8 +1540,8 @@ php-ts-mode-run-php-webserver (defun php-ts-mode--webserver-read-args (&optional type) "Helper for `php-ts-mode-run-php-webserver'. -The optional TYPE can be the symbol \"port\", \"hostname\", \"document-root\" or -\"router-script\", otherwise it requires all of them." +The optional TYPE can be the symbol \"port\", \"hostname\", \"document-root\", +\"router-script\" or \"config\", otherwise it requires all of them." (let ((ask-port (lambda () (read-number "Port: " 3000))) (ask-hostname (lambda () @@ -1546,17 +1557,25 @@ php-ts-mode--webserver-read-args (read-file-name "Router script: " (file-name-directory (or (buffer-file-name) - default-directory))))))) + default-directory)))))) + (ask-config (lambda() + (expand-file-name + (read-file-name "Alternative php.ini: " + (file-name-directory + (or (buffer-file-name) + default-directory))))))) (cl-case type (port (funcall ask-port)) (hostname (funcall ask-hostname)) (document-root (funcall ask-document-root)) (router-script (funcall ask-router-script)) + (config (funcall ask-config)) (t (list (funcall ask-port) (funcall ask-hostname) (funcall ask-document-root) - (funcall ask-router-script)))))) + (funcall ask-router-script) + (funcall ask-config)))))) (define-derived-mode inferior-php-ts-mode comint-mode "Inferior PHP" "Major mode for PHP inferior process." -- 2.46.0 --nextPart3491391.LZWGnKmheA--