Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124343 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 E78511A00B7 for ; Wed, 10 Jul 2024 12:33:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1720614925; bh=F3Ln29MCQOfyLcdlw/pllQujFHXsNtxQl6GFA/L6bYQ=; h=In-Reply-To:References:Date:From:To:Subject:From; b=lOSNEIn1S3G/hghoQ3+ERnberft4xIQR9sVI208zi4UR9yIvs4/xz8Oof6az69lBg quGafm1jQQhJ9QCgUnSPtBp8zyWDwhEDPtpa99bc7Q2DsopgZ13ihTGvI2KtelzsXs nGYQnVnfAq7pHJof4niR/AswocjdngimuIJ63WslEfZpUWnszsT2uLv1ReI5UzuBTi LwS5JoT6zTRJpRiGlera2aF72/IMffa7QQtzwyqyk5TGbIxaOC7Ragmo2sgaKJwz0t eqWeX2rrPMRM7zqY+bnaIwbKwwhzJVYaKEAP7WdZwXl5mDbfp4GKhlaxHWjzMcqd9w qnGTppo5b7hXg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9CA05180082 for ; Wed, 10 Jul 2024 12:35:24 +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.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout7-smtp.messagingengine.com (fout7-smtp.messagingengine.com [103.168.172.150]) (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 ; Wed, 10 Jul 2024 12:35:23 +0000 (UTC) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.nyi.internal (Postfix) with ESMTP id CAD691384F58 for ; Wed, 10 Jul 2024 08:33:57 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute6.internal (MEProxy); Wed, 10 Jul 2024 08:33:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1720614837; x=1720701237; bh=ts02X9WMH/ fkJLNpcelMMLA6s2TJxEQbsThQqsBx5Rc=; b=vBtVeHYQxu3sbn6MMMaFmtE6+x 0/8OUEkNo6cugH54YBDdLXGfeJFjCi8bBB/TGqPr36I+GSab9mQXzTDbq1wJB1II 6TAJKA/5wn9tvdBAen7a4fgE1hoHvKMWAgnwFhcR4f1pe/dxGoyh3eSHI3XVOd5L ywZsdSBsoEmCizg0SMrTp/1C4yjEZfKPPxw7RFS1MGNir8b80ZFZXJpYoVwnWuaP lwadI0rquSq6zm1VKUoj6hEISmG8IV1YLU8xiikAPGVsC6fdomOPR4QKcHBhSiv8 1IPlN8vgPqsK6npZGdhr6FNhVVYqDBbLddf7WuzRxv3syK3zMpTuCFsYIK9w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1720614837; x=1720701237; bh=ts02X9WMH/fkJLNpcelMMLA6s2TJ xEQbsThQqsBx5Rc=; b=IxVQXLIt/zfd3XmMbIGWl5ovhlhTjCu4d5jts9Tok216 gLjNJgqzKlqGJstmZWNyu3EcbSYIWPD9VtI9mEPwgjHySExrS1bQKqzCMDSjiP1t b7f2ruHiPVGgShTbzIsorCQRBGNC/D9Rrim1U9QnXTwcrpeuDqmplvKKNJQCmZ5y 5YWb3Dzx/8c80X+fYZn3B7UMg/KC8owHFk70j5TLWpZoyxvRY9aBTxcAHlaHXD4S 2cDL184EV40+O7O3VKYCP2eIWQjuNSqnrDOJ0o4Jd6896EW2Vx67l0+cwq0A9LSn hcfTQHQ1D0n/Yzgruzw4GTshIo5aGPXUeDIbsd4v1w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrfedugdehfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedftfhofigr nhcuvfhomhhmihhnshculgfkoffuohfrngdfuceoihhmshhophdrphhhphesrhifvggtrd gtohdruhhkqeenucggtffrrghtthgvrhhnpedtudeiieffleevtdduteeuffegteevtedu ueefgfekvdekffeitdfgveeuveehueenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpehimhhsohhprdhphhhpsehrfigvtgdrtghordhukh X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 424221700093; Wed, 10 Jul 2024 08:33:57 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-568-g843fbadbe-fm-20240701.003-g843fbadb Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: <3c09786f-705d-4601-91a0-d2498304bbd7@app.fastmail.com> In-Reply-To: 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> <4F720A7A-B7DD-4B31-B0C9-6907419B53A5@newclarity.net> <7b40e925-d642-4cf4-83f8-f903a9964362@app.fastmail.com> Date: Wed, 10 Jul 2024 13:33:35 +0100 To: "php internals" Subject: Re: [PHP-DEV] [PHP-Dev] Versioned Packagers (Iteration IV) Content-Type: text/plain From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On Wed, 10 Jul 2024, at 07:38, Mike Schinkel wrote: > The request is to add class maps with a PHP-standardized format into > PHP core so that when a library of code needs to register classes to be > autoloaded they can contribute to a cascading of class maps where ONE > internal function checks the single union of all class maps for a > mapped symbol before turning over control if no such symbol is found in > the map to the procedural autoloaders that are currently available. > That way *any* PHP code could register its own class map without having > to get the core app to rearchitect itself to allow that to happen. Everything you've just described is possible, today, with no changes to PHP core. And the easiest way to implement it is to borrow the existing battle-tested implementation in Composer, maybe tweaking it with plugins, and automating it with its PHP API rather than using its CLI interface. If you look at "vendor/composer/autoload_psr4.php" in a project where you've run "composer install", you'll find a mapping of namespaces to directories; PSR-4 then defines where individual classes are within each of those directories. If you tell Composer to dump an optimized autoloader, it will instead create a mapping of individual class names to file paths. So let's step back a second, and look at the pros and cons of implementing it in core: Pros: - Possibly a bit faster if the C code can be optimised - "Blessed" by the PHP project, which makes it a standard of sorts - No library code to copy or install into a project Cons: - Requires a minimum PHP version to run (a huge problem for WordPress, famous for its broad version support) - Improvements can only be accessed by updating PHP - Breaking changes are nearly impossible, because users can't choose between major versions within one version of PHP - Limited ability to tweak for a particular project if the standard solution doesn't meet their needs Things that won't change: - You still need a standard layout of files within each directory (e.g. PSR-4, or whatever layout you prefer), or to run something that analyzes your code and generates a comprehensive class map (i.e. does the same job as Composer's optimized autoload generator) - The application still needs some central code to register those directory or file lists, e.g. when you install a WordPress plugin, something has to load its configuration file - PHP still won't be able to have two classes with the same name, because that's a completely separate problem, unrelated to autoloading Regards, -- Rowan Tommins [IMSoP]