Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124225 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 91CAA1A009C for ; Fri, 5 Jul 2024 01:16:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1720142266; bh=OWU3JGhgEx9Uya7ajoBqpvu4JaHdypDAWoLMkshVR28=; h=References:In-Reply-To:From:Date:Subject:To:From; b=Gk2ZYVPOM1d3QahfRwk4ubyhma950+iVU668rNNnwD+9d4xJaEl1aNgCq3PyhG52T eIRmh07jr5bhnEtBjDyeigBc/emhuF9dHOfNhG8Da6iFVZaSOnHTItip/jwWIxx3hr eMDVyaeN6nS0H89F1bVn+Xqa0a68ehoK3pPCT2ahzGZCmuXpWwPEzKM+aDafyzlfCY T2J+gYRVJgpgmk7S0trxmmdwcmyS85vkt7oeyWyM0jtwvni72SR7C68dsMhbFc9wvQ VDejpknomj7EvhlBOOVei36vkTuWqSrEzd3kLbLg5nRtlsnBoC9xqYph9DDudn6rqv PuobGW0kkkQiA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 1C619180052 for ; Fri, 5 Jul 2024 01:17:46 +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-qv1-f52.google.com (mail-qv1-f52.google.com [209.85.219.52]) (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 ; Fri, 5 Jul 2024 01:17:45 +0000 (UTC) Received: by mail-qv1-f52.google.com with SMTP id 6a1803df08f44-6b5e0d881a1so17403586d6.1 for ; Thu, 04 Jul 2024 18:16:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720142182; x=1720746982; 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=106Vfo1sBZG6fXrxIWBSEjw+G7+ys1QNansuUFsX614=; b=a+fmWl7U8/Ncr2lg+H0Jo+iEsWFT/SfFxfwmvSJzz8+CaIIzXx1QMuLRJZp/9NtHc6 VZFoTcpJecty62nNK6+NMYpYzR9iCbrTSqW0OTTiKYsOO7rLyp5rBbo+oFsDs2e/Xzu9 bL7VY9JytFNkjvsb1K94GGPt1yU0nGlOAQuFQ8dMetNBgp/4ZIflZPP2J+roh0aTIRz5 42ekJjabSg5mimJNrbZR18quaRNAeS/PLTcN3kTSSAVvP3ItFn+/G40B+QuOSCZxt+iW VMFnZoxzLHrAnp6jBZ9UWSsQkEXoYIvbbUAwTrxuKAjh1YAiY7cREv9h0ie8Kg9MpNHZ HCDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720142182; x=1720746982; 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=106Vfo1sBZG6fXrxIWBSEjw+G7+ys1QNansuUFsX614=; b=iTRIKp0riYv54aXbC/4Uw8X+mxKQZh+CsZzyO2sM7vpJQU9XbxIlxXHoOMEdbVJ8sA nQThcIeKaSxOQeChOw8WcLkaZNeXn9BwcktMvbZjmeOcorl914pEBhfLfGjEAEymc+Cr /4BV4FU/Fn1JOY8qOb4FHkhyHZ5NQC7+dwsH1V/1xjfrdrr3k1/mrY/EuHkxnn149F6D 9C7t1l8RtcnKKCOxgqLTZqgsJV4qQwEdmUmXm/9Mig3F7Py0ADmqO/8pqRz9/unZ8z0W a1q4DqIP4eYtLGK93Kno3GvgUIVIpYh0rcbnATM1MHeuiiWgamCfthyHUdQTBfSo99av 8EPA== X-Gm-Message-State: AOJu0YxTii7/gX4d5D7s9OPSNXUSmlCrm5nV0Bn1u18f89kgvmLQe31R 0Fir01VFRvuCFhvO+FYJQmJWsQo5+S8ldZXeMUSLu1Cpc+BOh4BqS8fn8l/tpPKvQWwWBo2sdLA n4yAG2hcZT8zRmwrKhGFGWH0d+HgCbwcR X-Google-Smtp-Source: AGHT+IGCnVdPiiDkRdfWOfrvyA/+jgFRcEmW1RQGnA/6W610f/Jg80sAXwl3OPZpO8XssK1sxwBozAGAx4aTKPoVL0s= X-Received: by 2002:a05:6214:f22:b0:6b5:8015:d72d with SMTP id 6a1803df08f44-6b5ee56a52amr49346146d6.8.1720142181859; Thu, 04 Jul 2024 18:16:21 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <09559430-4477-4516-8D78-6F4071E1AA6C@newclarity.net> <0182F3D6-F464-477F-9029-A2D0A8B50C71@koalephant.com> <1AFD7AAE-8BEA-460D-88A8-15BB3D30A775@koalephant.com> <7B633CC7-C768-4852-A4D0-B252A04F7DE1@newclarity.net> <0E11F373-99DC-496E-9BBC-2F8688B9F66A@newclarity.net> In-Reply-To: <0E11F373-99DC-496E-9BBC-2F8688B9F66A@newclarity.net> Date: Thu, 4 Jul 2024 21:16:11 -0400 Message-ID: Subject: Re: [PHP-DEV] [PHP-Dev] Versioned Packagers (Iteration IV) To: PHP internals Content-Type: multipart/alternative; boundary="000000000000b687b4061c75cf76" From: tendoaki@gmail.com (Michael Morris) --000000000000b687b4061c75cf76 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jul 3, 2024 at 11:11=E2=80=AFPM Mike Schinkel = wrote: > >> import 'file.php v1.0.0'; > > > > Where will PHP be able to get the version number in a performant manner= ? > > > > A question for another day. > > Frankly if your proposal hinges on using version numbers to differentiate > then I think it is not something you can postpone answering. > > If there is not a good answer then the approach you are exploring is moot= , > at least as far as I can see. > > So I've had more time to mull this over, and some research, and I think I have an approach. First, instead of 'import', use 'require_module'. The parsing rules for require_module differ from require how the file is parsed, a subject for another time. Also, it's parallel to what is to follow. Speaking of new functions, let's start with these spl_set_include_ini_map('importmap.ini'); spl_set_include_json_map('importmap.json") The json file is pretty much identical to the JavaScript importmaps. The ini file looks like this root =3D "/absolute/path/to/application/root" [imports] square =3D "./path/to/square.js" circle =3D "./path/to/circle.js" other/ =3D "./path/to/other/" [scopes] \A[square] =3D './path/to/square/in/namespace/A/a.js' Whichever format is used is a matter of personal preference. The file can be, and likely should be, written by composer or some future package manager. The root attribute in the map sets the root for all relative paths given in the map. Imports are the standard imports for the project. The token on the left maps to the target on the right. Import maps affect all includes. Import map tokens are considered before anything use on the include resolution rules. So `include 'square'` would bring in '/absolute/path/to/application/root/path/to/square.js' given the ini file above. An import token ending in / is a prepend and the path it maps to must also end in a slash. So `require_module 'other/triangle.php' will map to '/absolute/path/to/application/root/path/to/other/triangle.php' given the ini file above. Scopes have a namespace followed by the token in brackets. Scopes only affect require_module as the other include mechanisms do not pay attention to namespaces. When in that namespace the specified file will be loaded instead of the default outlined in imports. The import map system is inspired by but not exactly like JavaScript's https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/impor= tmap This approach gets whatever RFC that comes out of this proposal out of the business of trying to design a package manager. --000000000000b687b4061c75cf76 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Wed, Jul 3, 2024 at 11:11=E2=80=AF= PM Mike Schinkel <mike@newclarity= .net> wrote:
>>=C2=A0 =C2=A0import 'file.php v1.0.0';
>
> Where will PHP be able to get the version number in a performant manne= r?
>
> A question for another day.

Frankly if your proposal hinges on using version numbers to differentiate t= hen I think it is not something you can postpone answering.

If there is not a good answer then the approach you are exploring is moot, = at least as far as I can see.


So I&= #39;ve had more time to mull this over, and some research, and I think I ha= ve an approach.

First, instead of 'import'= , use 'require_module'.=C2=A0 The parsing rules for require_module = differ from require how the file is parsed, a subject for another time.=C2= =A0 Also, it's parallel to what is to follow.

= Speaking of new functions, let's start with these

<= div>=C2=A0 spl_set_include_ini_map('importmap.ini');
=C2=A0 spl_= set_include_json_map('importmap.json")

Th= e json file is pretty much identical to the JavaScript importmaps. The ini = file looks like this

=C2= =A0 root =3D "/absolute/path/to/application/root"

=C2=A0= [imports]
=C2=A0 square =3D "./path/to/square.js"
=C2=A0 c= ircle =3D "./path/to/circle.js"
=C2=A0 other/ =3D "./path= /to/other/"

=C2=A0 [scopes]
=C2=A0 \A[square] =3D './pat= h/to/square/in/namespace/A/a.js'
=C2=A0
Whichever = format is used is a matter of personal preference. The file can be, and lik= ely should be, written by composer or some future package manager.

The root attribute in the map sets the root for all relati= ve paths given in the map.

Imports are the standar= d imports for the project.=C2=A0 The token on the left maps to the target o= n the right.=C2=A0=C2=A0
Import maps affect all includes.=C2=A0 I= mport map tokens are considered before anything use on the include resoluti= on rules.=C2=A0 So `include 'square'` would bring in '/absolute= /path/to/application/root/path/to/square.js' given the ini file above.<= /div>

An import token ending in / is a prepend and the p= ath it maps to must also end in a slash.=C2=A0 So `require_module 'othe= r/triangle.php' will map to '/absolute/path/to/application/root/pat= h/to/other/triangle.php' given the ini file above.

=
Scopes have a namespace followed by the token in brackets.=C2=A0 Scope= s only affect require_module as the other include mechanisms do not pay att= ention to namespaces.=C2=A0 When in that namespace the specified file will = be loaded instead of the default outlined in imports.

<= div>The import map system is inspired by but not exactly like JavaScript= 9;s=C2=A0https://developer.mozilla.org/en-US/docs/Web/HTML= /Element/script/type/importmap

This approach g= ets whatever RFC that comes out of this proposal out of the business of try= ing to design a package manager.


<= /div> --000000000000b687b4061c75cf76--