Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121003 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 20736 invoked from network); 7 Sep 2023 05:12:44 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Sep 2023 05:12:44 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 89B97180511 for ; Wed, 6 Sep 2023 22:12:42 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS63949 74.207.240.0/20 X-Spam-Virus: No X-Envelope-From: Received: from malamute.woofle.net (woofle.net [74.207.252.100]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 6 Sep 2023 22:12:41 -0700 (PDT) Received: by malamute.woofle.net (Postfix) with ESMTPSA id E456A1EF2C; Wed, 6 Sep 2023 22:12:39 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) In-Reply-To: Date: Wed, 6 Sep 2023 22:12:29 -0700 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: <5730FB2B-F89F-451D-BBE9-AA9871AE7325@woofle.net> References: To: Hanz X-Mailer: Apple Mail (2.3731.700.6) Subject: Re: [PHP-DEV] FFI [was: Breakages with rc1] From: dusk@woofle.net (Dusk) On Sep 6, 2023, at 19:18, Hanz wrote: > On a totally different note... I'm trying to get my head around FFI > specifically how it could = be > used to orchestrate 3rd party pipelines, like those of python. That isn't a particularly good use case for FFI. If you're trying to = call Python scripts, you're probably looking for popen(), proc_open(), = or something like the Symfony Process component (composer require = symfony/process). FFI allows PHP scripts to load and call functions in C libraries. This = can allow PHP scripts to access functionality which doesn't have PHP = wrappers available. If you're on macOS, here's a silly but functional example which calls = the NSBeep() function to make your computer beep: $ffi =3D FFI::cdef(<<<'EOF' void NSBeep(void); EOF, "@rpath/AppKit.framework/AppKit"); $ffi->NSBeep(); sleep(1); (Don't worry too much about the @rpath bit.)=