u/Sentient_Blade
In this archive from Feb 2017 to Mar 2022
- 23
- posts
- 1.1k
- comments
- 4
- media
- 7.5k
- score
Top posts
PHP UK Conference videos available
youtube.com/channel/UCX06sx2WWYGny7b3XDUyFCQNot downloaded yet
[RFC] Opcache Preloading (Dmitry Stogov)
Summary Removes significant overhead in PHP request-process-response cycle by allowing a developer to pre-compile common library / framework / application code when the PHP process first starts. These functions / classes would then be always-available without include(...)'ing them. Limitations Would...
PHP 7.2 Release Manager: Start planning to upgrade from 7.2 NOW!
twitter.com/SaraMG/status/1167593974737133569Not downloaded yet
Internals on Reddit: Superglobals Read-Only
https://externals.io/message/100087 Linked here for contributions from those without easy access to post to the internals group. Suggestions include making $GET, $POST, $SERVER etc read only in PHP 8, understood to be a breaking change. Edit: BTW, the suggestion came from Sara Golemon whom is one of...
Unpopular opinion: People should stop prefixing popular opinions with "unpopular opinion".
The answer is... it depends.
Under normal circumstances, when a file is compiled it is converted into a series of opcodes which can represent not only instructions, but things like how to define classes as well. Those opcodes are all stored in an array.
When the file is executed, it runs that array of opcodes, and when it encounters an opcode which declares a class, it creates the internal definition for it. It's only once those opcodes have run that the class (or function etc) becomes available to use in userland.
Because the process of converting source code into opcodes is quite an expensive one, there's a core extension called opcache. The main purpose of opcache is to store that opcode array in shared memory, so that the next time that particular file needs to be run, it can skip over the parsing / compiling, and just copy over the opcodes into active memory, speeding the whole process up considerably.
There was still one extra element, which was that even though opcodes define how to construct a class and its functions, that's not the whole story, as the classes which have been created might rely on other classes, interfaces, traits etc, so it's the job of another piece of code, the linker, to look up all of those external dependencies, and connect them up, and do any additional checks (such as making sure method signatures match).
Importantly, the linking process has to be done for every request... because of the way PHP works, you might define the same named class in two different files, and even though it's named the same, it may be significantly different... it's very bad practice, but it's possible... so the linked results get dumped after each request.
Now that used to be the end of it... until PHP 7.4.
The latest version of PHP introduced a new tech called "preloading" and its job is to effectively eliminate that last section of linking things together.
With preloading, the first time the PHP executable is run, you can compile all of your classes (and those belonging to frameworks etc) and then run the linker over them before it ever processes the start of a single request.
Once all of this linking has been performed and everything is connected up, the entire block of memory, including all of its inter-connected class definitions, is effectively cloned into each new process, completely skipping the need to run opcodes to define or link classes, because they already exist in memory (so autoloaders never get called).
This offers a small but meaningful performance boost when using code and libraries with lots of classes. It moves all the work to the start of the process, doing it only once, rather than every time a new request comes in.
Jetbrains hiring Nikita was one of the best things to ever happen to PHP.
PHP is an actively developed language that gets powerful new features on a yearly basis. It supports modern design philosophies and provided you're disciplined in your coding, it can have excellent scalability and performance.
It's lacking some powerful features for sure (generics) but the talent pool to add them is quite small, there's probably only 3 or 4 people in the world who have the skills and time to add that.
Really it's all about what's the right tool for the job, and often times PHP is the right tool for server-side and background tasks. Sometimes other tools are more suited, node for long-running web processes, react or angular for the front end, even a bit of C every now and then when it's really necessary.
I will say the Apache in LAMP has been widely replaced by NGINX + PHP-FPM nowadays.
It's definitely worth learning platform options, as mentioned in other posts, docker and k8s are huge and are only going to get more important.
visible confusion