Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104791 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 41804 invoked from network); 19 Mar 2019 02:54:17 -0000 Received: from unknown (HELO mail-ot1-f66.google.com) (209.85.210.66) by pb1.pair.com with SMTP; 19 Mar 2019 02:54:17 -0000 Received: by mail-ot1-f66.google.com with SMTP id 103so710066otd.9 for ; Mon, 18 Mar 2019 16:45:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xWA/4ik8/A16c2mOG1+mmt09jbGHUHtxeJWXAW+gkec=; b=j/H+hLM0hTld3BvOig3GweKUDNFjYXDpvdKZDZ6Pd9woSPeV6BLaScsopT37h/Egk+ 4ynR4iMKODeoM6s2G0euPXGtSpsDdQR6vPVvbQ06UYms5qM/x1vVXiC0mZ9Vda9ldqK0 Llew4n5VB9GAuB99bI6DzNxTtIF9x1BcV9TxiRwScpojWNiAP7X2GF9BbXCygwJNShG+ SbM6wOxwGepARprjxSwoWjVWsRECLOf6dc0al16G+EBamCgDd8VwE5qCB2CaxT0Ctuer yIMbXgUZyPviAJcBJ+ashAv1wbd5T8pQzBmmGsHiMFHOJJ6hgVWELNDrmp4K0dhZ59nw Oyuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xWA/4ik8/A16c2mOG1+mmt09jbGHUHtxeJWXAW+gkec=; b=rw91h8UfiCY4S4IUyZ8PQb5vniHwzcfFk80/3pWgl0IlLxIQi7xLMIMOcxo4qGDcnU sWNvFg1q5CocqQrzaqo2vtrMK3YIgTFRQAOBfdrds9PVDdkPNDEzj8NKb6xpo/GuiZr1 WrSAq/pdbFDRzx9nfz4on9xE+hMKzqNl9WmlagTPtMAG/f2vEbfENxAzIu/2cXmeBXqu KM4ONL+d4Nlddb6YuEpyVvAsXj982x96tPDwqaN/dXj4g2yrfLIQh30Tm1Vpx9XGAX1P dMJLy6RORVHknOpC8zl+GFAFPsQhx4/oKE3Hc+VgZTAV0KcrxAmX3gDv9cVOjD2Xvbzk mH+Q== X-Gm-Message-State: APjAAAX/L5MMzlzNGaRRuS/iGowNjt9TUrxu/SyyDK/NXXLqbhS2/j3i 12Fsk/XpZaHnmoyEFvV6hWwgauNjBJjgbnPSYJQ= X-Google-Smtp-Source: APXvYqzvo8K6USdC0QF2vYFvA7Tyd7ez5+hWYRKGumO+ABhRX3o7OnM+sks81kSgiyM8SthNKiTAByUxquu/wj2/bmw= X-Received: by 2002:a9d:5e14:: with SMTP id d20mr12917216oti.172.1552952747430; Mon, 18 Mar 2019 16:45:47 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 18 Mar 2019 23:45:35 +0000 Message-ID: To: Rasmus Schultz Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] unload/reload classes? From: robehickman@gmail.com (Robert Hickman) (I'm not a internals developer, but here are some ideas:) 1: I have seen an extension which allows functions/classes to be redefined, although I can't remember what it is called. 2: It is possible to dynamically reload code if defined as anonymous classes or functions using return include: $class = include "file_1.php"; $class->some_function(1,2); ---------------- This would entail creating a custom namespace system, and a facility to watch and re-include files. I don't know if the old bytecode of 'orphaned' objects would be garbage collected. 3: Another option would be to create a watcher on the files and just kill and reload the php process on file changes. This would be easier if the application state is all stored externally. 4: Use Ruby/JS/Python instead? On Mon, 18 Mar 2019 at 20:16, Rasmus Schultz wrote: > > Hello internals, > > How hard would be to add an unload (or reload) feature for > classes/interfaces? > > I'm wondering with regards to running PHP as a deamon (with Swoole or > ReactPHP, etc.) could it be made possible to hot-reload e.g. for > controllers and view-models? > > Of course, the other option is to launch worker sub-processes under some > sort of host process, and then restart the workers after a change - this > adds communication overhead between the host/worker processes though, and a > layer of complexity. > > Another option is if a reverse proxy (NGINX maybe) could restart the actual > application daemon, but that means you have a dependency on a specific > reverse proxy. > > So I know there are other options, but I'm looking for the simplest and > cleanest way to do this, and I'd prefer to stay within the language. > > Other dynamic languages (where daemonizing is "normal", like Ruby, JS and > Python) have this feature and it is often used to hot-reload > controllers/views in web-apps. > > Any thoughts?