Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124128 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 08BAD1A009C for ; Mon, 1 Jul 2024 05:33:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719812071; bh=P6Tw2TU8AsVlyXhkGw9Y+vzGFNT0/dgkuVcRH2BYJ1o=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=NkKujjkLMZXzLl+P0eVilPEmhesk6MHAQh7Wa5665SosItQmux7hVqTaQvBUpJ89n I0dsXf/pC8OptiXa+cx70HrGP1JMPsQ+XSoCVRG9iPCOiAoPE/GDHvpIT+FbI4xP6v SVFh78BMLlscvOiQKhT1/b0BxuOIXwrs60wVBHui+E6R2W9IuishH6E74hkaYF3DiQ Hg0kePr5nlzfqOoYJtEYVUt5DZkyjoYA0F5vnS4EivS8jGoc7NabKDwpOpXpZcn1tZ UfVQG1tH5meS9MHCB39F1PO9e3yJAKWD0ZBY6pP14MkXnPcxVawP2UZc0Seb0NxuIq nNMWt5rsiTUAA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7177F180685 for ; Mon, 1 Jul 2024 05:34:30 +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-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) (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 ; Mon, 1 Jul 2024 05:34:29 +0000 (UTC) Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-64b417e1511so22352817b3.3 for ; Sun, 30 Jun 2024 22:33:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719811989; x=1720416789; 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=I7kfdC1S4Vql1JG/3RWtITwBj/ATeQEz2yGvU4y7wIA=; b=gDA4MB4NXEG2VXfJ2F6DYV0X6gYx4yYxdbBxKeWgVkTOVn9rJ+I3R/rGAMwq40jQU4 ViSsAiZOQkSHvC8ylmp9IRPSPZ3UxHvt4zdbfK7/0QHHCQUY9mGKdLX0cXwSfrjnTTrx TLSIwRomn2hHfWolCjcLUkiQsuLUK8KWCHUE0mdNYo2+AwG3Tm+4ZITOzn6jZi1HV40U mxa4R2glkKF/SIxjWBEDqXE8WY7C6SDiTGQ3vA8jCb3xYkadcFMJJjUvbZEjPzoNV40f RKgYSjaK5qmv4NVLKHMeEdGxPgVxl5Or6tBXSMd2dhHn6mo3isWWppQxL413wU857rPj fiuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719811989; x=1720416789; 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=I7kfdC1S4Vql1JG/3RWtITwBj/ATeQEz2yGvU4y7wIA=; b=FDG6wu9ArA+ez7Wjq14DHdO7LNihcDbss9aPFReC5YW3ok6VpeLSLCGqxs9KAut/PP VdkJe+YiaSuxeRVQ6haCYrk/cdNLTtPllnrVtnqMe17mnEm++E6pmHEO4r4qFNflhLk1 K6Lp4bkJTV1PboCYgqZSSPqGhNagqjaezzZoPOw1K6UAC5QsqgTfDPdqDRJkDgRGza0j KqtKX3yLpsc9FXHFKl9ZbOoLzf1Jp89QpYtj3Tmons2fQE6jSmU6F/SRru9icsfizD1f 6l9gB3m1N3Hho7OaGa7pgOkX4l5Mn+hf5/e2Tlp71pA+ZIXu5PgvT41V7NPEXAZUpoot bFxQ== X-Gm-Message-State: AOJu0Ywvm/ZAnXBBwrbbu5AmbBYyspi7wblaWl8rb/8FOEDcNPhNZQx7 /n/13WGQpvAokbrkzLQjja5T0MXDoGawOpqBh293ZLyoE6+5iU0aDm5kkEJOsFliWTwoWY0tmIB WLU3qW/WOGy565YHTzCUFXl+kOMRI2KoXfQs= X-Google-Smtp-Source: AGHT+IE4vbU1XkwPNTFQw/Q6IONAfAy2wMsg6fOcZlyl8IrSDjy8PZrn7IGHLd0RoJ2rCPSsPsRZGj5wmzcFFvynQw0= X-Received: by 2002:a05:690c:88f:b0:64b:9f5f:67b2 with SMTP id 00721157ae682-64c71fc23cemr48061437b3.31.1719811988785; Sun, 30 Jun 2024 22:33:08 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <1917CF7C-26D8-4DBE-B05C-5AA650AC6C9F@rwec.co.uk> <551cd5b0-1c00-4818-a9ca-97f6b7e8c3dc@app.fastmail.com> <39B496F8-062E-4848-9B3B-529BE8D3415A@newclarity.net> <856F4F70-DC81-4098-82DD-5F6D47CDF3F0@newclarity.net> In-Reply-To: Date: Mon, 1 Jul 2024 07:32:57 +0200 Message-ID: Subject: Re: [PHP-DEV] Packages Iteration 3: was Re: [PHP-DEV] [Initial Feedback] PHP User Modules - An Adaptation of ES6 from JavaScript To: Michael Morris Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000ac1351061c28ee35" From: michal.brzuchalski@gmail.com (=?UTF-8?Q?Micha=C5=82_Marcin_Brzuchalski?=) --000000000000ac1351061c28ee35 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Michael, pon., 1 lip 2024 o 01:18 Michael Morris napisa=C5=82(a= ): > ... > Applications > > The application is the root package. It is the package that imports to th= e > root namespace. When PHP is asked to parse a file it will look for a > `.php-packages` folder, first in the current working directory then in > parent directories. If it doesn't find one, business as usual. If we do > find one we follow its directives about setting up an application > environment. > > The `.php-packages` folder is where PHP will put package related code for > the application at hand. Code written explicitly for these changes will > also put their package related files there - composer's vendor directory, > composer.json, composer.lock, and so on - rather than putting those files > in the site root. The folder is hidden to prevent web servers like nginx = or > apache from serving the files directly in any way. > First, you use the term Application then Site - decide. Not all PHP applications are HTTP Applications, consider consumers, cron tasks other daemons, these don't need the existence of either Nginx or Apache. Not all PHP HTTP Applications expose files to Nginx or Apache - most of these I know like Rest API give ZERO access to any application file to Nginx or Apache. > The .php-packages directory will have a configuration file called > `php.mod`. This tells the parser: > You propose to move `composer.json`, `composer.lock`, and `vendor` into a hidden folder with no good reason which simply adds more confusion. > Let's look at what such a file might look like for Drupal. For the moment > I'm going to use go.mod's syntax. The final syntax to be used, be it ini, > yaml, toml, json, is a discussion for another time. The part to focus in = on > here is what type of information do we need. > > package Drupal > > php 10 > > registry //packagist.org/packages composer > > init ( > composer install > ) > > require ( > ./vendor/autoload.php > ) > > imports ( > //getcomposer.org/composer.phar > ) > This looks like a completely new file format which simply makes interoperability harder, consider tools like GitHub Dependabot, PHPMetrics or other tools that analyze dependencies - what you propose requires implementing a parser in userland or other languages the tool uses. > The directives do the following: > ... > * init is the command(s) to run before the application is started for the > first time. > What is the use case for it I don't get it. Many PHP Applications are distributed as a container image with all dependencies already included. How would it work with multi-threaded environments, which thread would be responsible for running init? How do you solve concurrency problems then? > If this theoretical version of Drupal moves its composer.json and > composer.lock files into `.php-packages` then the autoloader doesn't have > to be required in the index.php file. Also, the application can be start= ed > without running `composer install` > `index.php` is just a common name for PHP HTTP Applications for modern frameworks like Symfony and others that one lays in `public/` folder as an entry point, often this is the only file in this directory. If I understand your idea correctly you'd like a couple of I/O operations on the filesystem to find the `.php-packages` directory in CWD else if not in the parent directory and so on rather than directly pointing where it is, right? Cheers, Micha=C5=82 Marcin Brzuchalski --000000000000ac1351061c28ee35 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Michael,

pon., 1 lip 2024 o 01:18=C2=A0= Michael Morris <tendoaki@gmail.com= > napisa=C5=82(a):
...
Applications

The application is t= he root package. It is the package that imports to the root namespace. When= PHP is asked to parse a file it will look for a `.php-packages` folder, fi= rst in the current working directory then in parent directories.=C2=A0 If i= t doesn't find one, business as usual.=C2=A0 If we do find one we follo= w its directives about setting up an application environment.

The `.= php-packages` folder is where PHP will put package related code for the app= lication at hand.=C2=A0 Code written explicitly for these changes will also= put their package related files there - composer's vendor directory, c= omposer.json, composer.lock, and so on - rather than putting those files in= the site root. The folder is hidden to prevent web servers like nginx or a= pache from serving the files directly in any way.

First, you use the term Application=C2=A0then Site - decid= e.
Not all PHP applications are HTTP Applications, consider consu= mers, cron tasks other daemons, these don't need the existence of eithe= r Nginx or Apache.
Not all PHP HTTP Applications expose files to = Nginx or Apache - most of these I know like Rest API give ZERO access to an= y application file to Nginx or Apache.
=C2=A0
The .php-packages dire= ctory will have a configuration file called `php.mod`.=C2=A0 This tells the= parser:

You propose to move `com= poser.json`, `composer.lock`, and `vendor` into a hidden folder with no goo= d reason which simply adds more confusion.
=C2=A0
Let's look at = what such a file might look like for Drupal. For the moment I'm going t= o use go.mod's syntax. The final syntax to be used, be it ini, yaml, to= ml, json, is a discussion for another time. The part to focus in on here is= what type of information do we need.

=C2= =A0 package Drupal

=C2=A0 php 10

=C2=A0 registry //packagist.org/packages composer

=C2=A0 init (
=C2=A0 =C2=A0 composer install
=C2=A0= )

=C2=A0 require (
=C2=A0 =C2=A0 ./vendor/autoload.php
=C2=A0= )

=C2=A0 imports (
=C2=A0 =C2=A0 //
getcomposer.org/composer.phar
= =C2=A0 )

This looks like a= completely new file format which simply makes interoperability harder, con= sider tools like GitHub Dependabot, PHPMetrics or other tools that analyze = dependencies - what you propose requires implementing a parser in userland = or other languages the tool uses.
=C2=A0
The directives do the fol= lowing:
...=C2=A0
* init is the command(s) to run before the a= pplication is started for the first time.

What is the use case=C2=A0for it I don't get it.
Man= y PHP Applications are distributed as a container image with all dependenci= es already included.
How would it work with multi-threaded enviro= nments, which thread would be responsible for running init? How do you solv= e concurrency problems then?
=C2=A0
If this theoretical version of D= rupal moves its composer.json and composer.lock files into `.php-packages` = then the autoloader doesn't have to be required in the index.php file.= =C2=A0 Also, the application can be started without running `composer insta= ll`

`index.php` is just a common = name for PHP HTTP Applications for modern frameworks like Symfony and other= s that one lays in `public/` folder as an entry point, often this is the on= ly file in this directory.
If I understand your idea correctly yo= u'd like a couple of I/O operations on the filesystem to find the `.php= -packages` directory in CWD else if not in the parent directory and so on r= ather than directly pointing where it is, right?

<= br>
Cheers,
Micha=C5=82 Marcin Brzuchalski
<= /div> --000000000000ac1351061c28ee35--