Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125994 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 399541A00BD for ; Tue, 19 Nov 2024 13:48:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1732024280; bh=X9akPWJoeAc3Ew82jgtl1B3+4eyVijTn+1dsLU7W/dg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=mDPzlyNOqFeU7VWHv7fF1GaepetHLnwwLQEs9UF5uLDJxQdu88yf+tmLPvoOPYPHG GbF3HOWtwVsWNm38Y/AQG9WLkJrUmmshypZiaeKAOb8smXh79rajwdbZy/kquftNOc 2nhpC+ouNxpe0CwFfnJMj1OOWg0qqt0YJKKCvuhFC7K1JZBxZChVcpdtrYgcwtsObN XF0vC1HkfobZ+eoBJeVIGvsfH8neoWj5nXaYHkxpqasDZv12hJzr3OQb+e8qI5WPdn ks42F9J/pSYeR07N7BuEoRX+cjXadA+bLdZyw2aHs5u54ulI73hsZ5wY9MhMQU6GHz fzxVMzr5C0u5g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4BDC7180080 for ; Tue, 19 Nov 2024 13:51:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 19 Nov 2024 13:51:16 +0000 (UTC) Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-71807ad76a8so1751739a34.0 for ; Tue, 19 Nov 2024 05:48:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732024117; x=1732628917; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=X9akPWJoeAc3Ew82jgtl1B3+4eyVijTn+1dsLU7W/dg=; b=nRQ4NeS8IvnlWhDznR6fyicUeRWldKQgOT+nph/P2bcAM4poXyZw0ZlyrxcV6fbPZ9 YvrTE7G1wjtGzPerouJCns5/QpniA39YQE/t7OY2Eu93C/It7HupRcRU59jLItsYyui4 isYk/hBLHeFWiBfCrAgRdniWn+06TsQwWRVvJ9Het4PIJ6EKSQiTDo/h3wSoLIJ2uqci jC7cYP9n0k3K5TnQ3YDay0wO1qbwRG75LPom45YJEoWHb7WLpla0tu3jpTDuIW8N5GWg f/Kui7U5rxGVEbLpoPu7nA55hXzwva40wPvAMNKdPJJ9EsMe35984v0IIBC8J/ezs7Xa U7Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732024117; x=1732628917; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=X9akPWJoeAc3Ew82jgtl1B3+4eyVijTn+1dsLU7W/dg=; b=HT/Meeyv7SNisAw2eLkh0RrlTeBYI4f++ifNzzDh/h5bC3riUWFDigLayNunGI7uXb eCbsOjU6PaetdnYyGHyr7opnlHXbr6c7fTkGYF7NXlB184oOS/+QoVsoL/zoJlyS86ie yTwAaj6f5WhE6Eft1O37josj9LdNuVw79W/rYKYllrr3WLsdKxH3/RdcXewybwXtDnr+ Y9IKHJufFeXqBosUwzDf0Rx08WN6GX0YPRXd27RZO2iU7DAz4WOe07C9M2pZv9U+oH/m ydjpbuEyEx0l1zUbJKrDsIskRGZhMVd/WA8adZ1F29QveCoDSp85uJ103bbFUxFCMuMa 7tdg== X-Forwarded-Encrypted: i=1; AJvYcCVMW6LOs4nZ0Rt0Rn/M9z34Z05VkKl+UkFFfk89CP5DlxYJZLuQayB6ajcAH7QrzWDAkML60eR2NkM=@lists.php.net X-Gm-Message-State: AOJu0YzYQKgCnnqiXVlthFaZMC8ncNr1s9Gv3gEpah7vS7wlPcjjXZnh oL5TPObuoTn781Q5zHTpsHXbz+XfrD3OqotRtNiqntUjjm0/Ol60o04U73fkzxS5hUm+EeBpCWB W4cTItFuRJ/qke+hHK6yAwyDZtJWnkQ== X-Google-Smtp-Source: AGHT+IGtW9h1F0gjkHRSSasgsTr9y19J/N09XDwfozQCyL6e79OwBb+5aEi5KnzDRUe9+u9qo0lg9psiHV5pW0AAGB4= X-Received: by 2002:a05:6830:661a:b0:718:c2e:a193 with SMTP id 46e09a7af769-71a7794fef3mr14352494a34.10.1732024117389; Tue, 19 Nov 2024 05:48:37 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <1ccdaa01-bbe7-4ac6-a7a9-db43f9e4537b@scriptfusion.com> In-Reply-To: <1ccdaa01-bbe7-4ac6-a7a9-db43f9e4537b@scriptfusion.com> Date: Tue, 19 Nov 2024 06:48:22 -0700 Message-ID: Subject: Re: [PHP-DEV] Better development streamlining of the built-in server To: Bilge Cc: "John D'Orazio" , PHP internals Content-Type: multipart/alternative; boundary="0000000000004279c90627444a16" From: hamiegold@gmail.com (Hammed Ajao) --0000000000004279c90627444a16 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Nov 19, 2024, 6:38=E2=80=AFa.m. Bilge wrot= e: > On 19/11/2024 13:26, John D'Orazio wrote: > > I don't understand why an application should not know which > > environment it is running in? > > I don't know if this list is the place to be discussing this, but here > goes: > > Typically you are injecting the environment name to have the application > switch to a different configuration to load a whole bunch of different > settings for that environment. Instead, you should be injecting all > those different settings directly. The reason is because otherwise you > are tightly coupling your application to a fixed number of known > environments, limiting deployment options. Instead, the application > should be environment agnostic, thereby enabling whomsoever deploys your > application to configure as many different environment types as they wish= . > > This best practice also avoids the temptation to code different logic > paths based on the environment name (very bad). > > Don't worry, this is a common mistake, and even popular frameworks like > Laravel and Symfony promote this anti-pattern to some degree. > > Cheers, > Bilge > So if symfony and laravel do this, whose best practices are we going by exactly, yours? Switching configuration is one of many reasons an app needs to know what environment it's running on. What if I want more verbose logging at dev time? Or want to bypass expensive api calls with mock data? Or want to make sure something is never called in production? Cheers, Hammed > --0000000000004279c90627444a16 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Tue, Nov 19, 2024, 6:38=E2=80=AFa.m. Bilge <bilge@scriptfusion.com> wrote:=
On 19/11/2024 13:26, John D'Or= azio wrote:
> I don't understand why an application should not know which
> environment it is running in?

I don't know if this list is the place to be discussing this, but here = goes:

Typically you are injecting the environment name to have the application switch to a different configuration to load a whole bunch of different
settings for that environment. Instead, you should be injecting all
those different settings directly. The reason is because otherwise you
are tightly coupling your application to a fixed number of known
environments, limiting deployment options. Instead, the application
should be environment agnostic, thereby enabling whomsoever deploys your application to configure as many different environment types as they wish.<= br>
This best practice also avoids the temptation to code different logic
paths based on the environment name (very bad).

Don't worry, this is a common mistake, and even popular frameworks like=
Laravel and Symfony promote this anti-pattern to some degree.

Cheers,
Bilge

So if symfony and laravel do this, whose best practices are we going b= y exactly, yours?

Switch= ing configuration is one of many reasons an app needs to know what environm= ent it's running on. What if I want more verbose logging at dev time? O= r want to bypass expensive api calls with mock data? Or want to make sure s= omething is never called in production?

Cheers,=C2=A0
Hammed
--0000000000004279c90627444a16--