Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123959 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 ECC771A009C for ; Thu, 27 Jun 2024 20:04:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719518726; bh=UnIQkX16hwlYDBKKja0KBQH3Stgk2r2FRlyQjdfgUFI=; h=References:In-Reply-To:From:Date:Subject:To:From; b=GbSqdeEwbCdCPMl5FgqyFhkAbv9U0KqJLZ1d8aaXjYmhmNhqvsIF3PglgT71mZgw9 QOTEaD39smh5PQVL4v/p9hFnOm0i8YQQJqDtfESgilI2m6eViX7ziAGMNTYmPYpbQC VvrWzMGbm57eoy4WpAa7EDRbOKOIPPKjhEnwhvIz0TM+CmJV0EhhMfwX+koyAN5vEg 115Oayv7bYhDHFpjVKz7xipbTRrI74V6bD82pEp4HhW/c7mrVnPhj8o0fFV2IYN9Y4 3cjHLkQODIlCKBjm5ZFwvwPpXUjqghF+qlUPp/B0bpEzIi5o/S1ZMjh99AmOnwuIzl Mef+/sXYSUqSg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 44659180644 for ; Thu, 27 Jun 2024 20:05:26 +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_H2,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-yb1-f179.google.com (mail-yb1-f179.google.com [209.85.219.179]) (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 ; Thu, 27 Jun 2024 20:05:25 +0000 (UTC) Received: by mail-yb1-f179.google.com with SMTP id 3f1490d57ef6-e032aaa4cd8so411649276.2 for ; Thu, 27 Jun 2024 13:04:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719518646; x=1720123446; darn=lists.php.net; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=TfY3W5HLah7kS30ndmyLvAibt2bncN1lD8/dDP8H6Oc=; b=TjJTfWWaXMG6inc5WJfp/vAp+2vLET3uLFmVvdMusttKwT2SdiKzxtg2h6VTrgeqxA Hj4gjQuG2vMGtOOIiWttWdI0Hp+jrv1zciDOCBNngRD03JWh1x9VYyyAFMk+G7byXXNe 9ERDIfx2MEVF5nKpqoOZe0MX8mgkFs2CR9doGpyUPSdR0DsozI9lR7jsp8IRi/y1C3Fs p0jJQXjtjHbgCcEGYzsiSyEAigF5RQi8T5Q4xOBlPfHcWuksWItxfmMdXGH4ZL2SiXs3 zwWJTUUr2TBMp1XV0r8vvuVOSqT97t/QvPIkjkP2FlQ4SCkK4DjlgKxbgFW6AnSbkHeu wJ0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719518646; x=1720123446; h=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=TfY3W5HLah7kS30ndmyLvAibt2bncN1lD8/dDP8H6Oc=; b=THX1ojd+CuheVYFwz5bnhdSTFHnJeC/blg7aEUsE/wua80bXo20ihgEy0ZBn2MCcMm wiKoYcsuyRcP4SvKMFK/MbbyAMVaCcveevyoIPKqzvipuA10xwFfc2JJeHRIa1ObZNHl 6brit8AGfKPJpd9MYS3WkD6CbgoqnbKP8XV2qQTcmCi6ExFvXEnS2ByH4cnUjAPgmLIA EaRKmq832jV/xlU1b9sDkTAMRfyGaB6lVuumzwG06pqhrChaOu7YKs/eYqbaNU2keTlo NHFla+aUke8KcOqe9zK0ez2N6f3PlCuO32NfcdvqmD1dcQ2ZCd23kvveD8+sE6b/s5yx cylQ== X-Gm-Message-State: AOJu0Ywucm0wx449tDwEVg3b+ZIj6NIn4G7hBFiUr3De4PvwN3avIEin YOUJSdAdXgYRC0GQLS6GzBXVq4XWnzjQtQNMxzhGBp8nY1n8l5jQZSfu5eFa45fIHRVD+of+czi jT8V02CbnQp36Di96nFtdSt3oAL688+bCX2M= X-Google-Smtp-Source: AGHT+IE72JLO8KDdZjqn+AnbiYqA+rgV2QtRRtm5l3CAosdhv4801N/TLcmQAhzkOeG+IkVpLMGdCEXnGNg1yY0VmQk= X-Received: by 2002:a25:7a45:0:b0:dff:164d:6f2 with SMTP id 3f1490d57ef6-e02f76f87e3mr12211492276.2.1719518646448; Thu, 27 Jun 2024 13:04:06 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 27 Jun 2024 17:03:30 -0300 Message-ID: Subject: Re: [PHP-DEV] [Initial Feedback] PHP User Modules - An Adaptation of ES6 from JavaScript To: PHP internals Content-Type: multipart/alternative; boundary="0000000000001b401b061be4a242" From: deleugyn@gmail.com (Deleu) --0000000000001b401b061be4a242 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jun 27, 2024 at 4:31=E2=80=AFPM Michael Morris = wrote: > > >> The fact there's weird behaviors as result of trying to import a file an= d >> suddenly a file all the way from `include_paths` or `php_modules` seems >> like a no-go to me. I'd favor using only simple file path navigation and= if >> the file doesn't exist, error. >> >> Perhaps if the idea gains merit, Composer could offer something similar >> to Vite where we can create an alias to a specific folder and then impor= t >> things like `from '@package/path/to/file`. >> > > Composer would need a massive rewrite to be a part of this since it > currently requires the file once it determines it should do so. If we do = a > system where import causes the parser to act differently then that alone > means imports can't be dealt with in the same manner as other autoloads. > Perhaps my point here wasn't so obvious. I wasn't talking about Composer making drastic changes to accommodate this, I was only merely mentioning Composer being used to provide something like the following: ```composer.json { "require": { "php": "^8.2" .... }, "php-modules": { "@packages": "./packages", "@utilities": "./tools/utilities" .... } } ``` Then whenever there's a `import Foo from '@packages/Foo.php'`, the notation `@packages` would be replaced by the packages folder. This is equivalent to Vite resolve.alias https://vitejs.dev/config/shared-options.html#resolve-alias --=20 Marco Deleu --0000000000001b401b061be4a242 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Thu, Jun 27, 2024 at 4:31=E2=80=AF= PM Michael Morris <tendoaki@gmail.= com> wrote:
=C2=A0
Th= e fact there's weird behaviors as result of trying to import a file and= suddenly a file all the way from `include_paths` or `php_modules` seems li= ke a no-go to me. I'd favor using only simple file path navigation and = if the file doesn't exist, error.=C2=A0

Perhap= s if the idea gains merit, Composer could offer something similar to Vite w= here we can create an alias to a specific folder and then import things lik= e `from '@package/path/to/file`.
Composer would need a massive rewrite to be a part of this sinc= e it currently requires the file once it determines it should do so. If we = do a system where import causes the parser to act differently then that alo= ne means imports can't be dealt with in the same manner as other autolo= ads.

Perhaps = my point here wasn't so obvious. I wasn't talking about Composer ma= king drastic changes to accommodate this, I was only merely mentioning Comp= oser being used to provide something like the following:

```composer= .json
{
=C2=A0 =C2=A0 "require": {
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 "php": "^8.2"
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 ....
=C2=A0 =C2=A0 },
=C2=A0 =C2=A0 &= quot;php-modules": {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 "@pack= ages": "./packages",
=C2=A0 =C2=A0 =C2=A0 =C2=A0 &= quot;@utilities": "./tools/utilities"
=C2=A0 =C2= =A0 =C2=A0 =C2=A0 ....
=C2=A0 =C2=A0 }
=C2=A0}
```

Then whenever there's a `import Foo = from '@packages/Foo.php'`, the notation `@packages` would be replac= ed by the packages folder. This is equivalent to Vite=C2=A0resolve.alias=C2= =A0= https://vitejs.dev/config/shared-options.html#resolve-alias
=

-- =
Marco Deleu
--0000000000001b401b061be4a242--