PHP 7.2.29 Released – PHP: Hypertext Preprocessor

The PHP development team announces the immediate availability of PHP 7.2.29. This is a security release.All PHP 7.2 users are encouraged to upgrade to this version.For source downloads of PHP 7.2.29 please visit our downloads page, Windows source and binaries can be found on windows.php.net/download/. The list of changes is recorded in the ChangeLog.

PHP Internals News: Episode 44: Write Once Properties – Derick Rethans

PHP Internals News: Episode 44: Write Once Properties

In this episode of “PHP Internals News” I chat with Máté Kocsis (Twitter, GitHub, LinkedIn) about the Write Once Properties RFC.

The RSS feed for this podcast is https://derickrethans.nl/feed-phpinternalsnews.xml, you can download this episode’s MP3 file, and it’s available on Spotify and iTunes. There is a dedicated website: https://phpinternals.news

Transcript

Derick Rethans 0:16

Hi, I’m Derick. And this is PHP internals news, a weekly podcast dedicated to demystifying the development of the PHP language. This is Episode 44. Today I’m talking with Máté Kocsis about an RFC that he produced called write only properties. Hello, Máté. How’s it going?

Máté Kocsis 0:34

Yeah, fine. Thanks.

Derick Rethans 0:36

Would you mind introducing yourself a moment?

Máté Kocsis 0:38

My name is Máté Kocsis and I’m a software engineer at LogMeIn. I’ve been using PHP for 15 years now. And after having followed the mailing list for quite some time, I started contributing to the project last October, and now Write Once properties is my first RFC.

Derick Rethans 0:58

What is the concept of Write Once Properties?

Máté Kocsis 1:00

Write Once Properties can only be initialised, but not modified afterwards. So you can either define a default value for them, or assign them a value, but you can’t modify them later. So any other attempts to modify, unset, increment, or decrements them, would cause an exception to be thrown. Basically, this RFC would bring Java’s final properties, or C#’s, read only properties to PHP. However, contrary how these languages work, this RFC would allow lazy initialization. It means that these properties don’t necessarily have to be initialised until the object construction ends, so you can do that later in the object’s life cycle.

Derick Rethans 1:48

PHP already has constants, which are pretty much write only properties as long as they’re being defined in a class definition. How does differ?

Máté Kocsis 1:58

Yeah, it’s it’s the difference because, so you can assign these properties value in the constructor or anywhere. You don’t don’t have to define them a default value.

Derick Rethans 2:12

Okay, and of course constants have the other problem is that you can only set its values to constants, not necessarily to any sort of expressions, or the result of other method calls.

Unknown Speaker 2:22

So you can use objects, resources, any kind of property value here.

Derick Rethans 2:28 You mentioned C#’s read only properties. And you sort of mentioned them in the same breath as write ones properties for PHP. These seem like opposite things

Máté Kocsis 2:39

Not quite opposite, but there’s some distinction between the two. C sharp requires these properties to be initialised until the object construction ends. And this is very difficult to achieve in PHP. And now I’m using Nikita’s words: Object construction is a fuzzy term and you can be sure if, if the contractor is involved at all. For example, if you are using Doctrine or proxy manager, so we decided to allow lazy initialization, which means that you don’t have to assign these properties a value, you are free to do anytime when you want.

Derick Rethans 3:22

Truncated by Planet PHP, read more at the original (another 11609 bytes)

Xdebug Update: February 2020 – Derick Rethans

Xdebug Update: February 2020

Another month, another monthly update where I explain what happened with Xdebug development in this past month. It will be published on the first Tuesday after the 5th of each month. Patreon supporters will get it earlier, on the first of each month. You can become a patron here to support my work on Xdebug. If you are leading a team or company, then it is also possible to support Xdebug through a subscription.

In February, I worked on Xdebug for just over 75 hours, on the following things:

dbgpClient and dbgpProxy

I have now finished work on early-release versions of a DBGp Client (dbgpClient) and DBGp Proxy (dbgpProxy). These tools are written in Go, and binaries can be downloaded from the download page. Source code is not yet available, but I am intending to open that at some point in the near future.

For Xdebug Cloud I can no longer have the debugging protocol going over the network unencrypted. I am therefore working at including SSL support in Xdebug, as well as in the dbgpClient and dbgpProxy tools. The tools already have support as it was easy to add that in Go, but Xdebug does not yet. I’ve done research and selected BearSSL to provide this.

Asynchronous Debugging Support

Robert Lu has been working on asynchronous support in Xdebug’s debugging protocol for a while, the #1016: Support for pause-execution issue. After extensive testing, review, and reworking of the patch by Robert and I, this patch finally landed in Xdebug. The asynchronous support allows you to pause scripts while they are running without a breakpoint to have been hit. This feature needs support in a debugging client, which actively needs to opt into this behaviour. The new dbgpClient from the previous section supports this.

I will be working with purveyors of IDE to also include “pause-exection” in their feature set.

Business Supporter Scheme and Funding

In February, a few new supporters signed up. They are:

Supermetrics, Private Packagist, and CHECK24.

Thanks!

If you, or your company, would also like to support Xdebug, head over to the support page!

Besides business support, I also maintain a Patreon page and a profile on GitHub sponsors.

Podcast

The PHP Internals News continues its second season. In this weekly podcast, I discuss in 15-30 minutes, proposed new features to the PHP language with fellow PHP internals developers. It is available on Spotify and iTunes, and through an RSS Feed. In the first episode I spoke with Nikita Popov about Preloading and WeakMaps.

PHP Internals News: Episode 43: Syntax Tweaks – Derick Rethans

PHP Internals News: Episode 43: Syntax Tweaks

In this episode of “PHP Internals News” I chat with Nikita Popov (Twitter, GitHub, Website) about the RFCs. One on abstract methods in traits, and one about an improvement to the tokenizer.

The RSS feed for this podcast is https://derickrethans.nl/feed-phpinternalsnews.xml, you can download this episode’s MP3 file, and it’s available on Spotify and iTunes. There is a dedicated website: https://phpinternals.news

Transcript

Derick Rethans 0:16

Hi, I’m Derick. And this is PHP internals news, a weekly podcast dedicated to demystifying the development of the PHP language. This is Episode 43. Today I’m talking with Nikita Popov yet again about a few RFCs that he’s produced for PHP 8. Good morning, Nikita. How are you doing?

Nikita 0:34

Good morning, Derick. I’m doing great.

Derick Rethans 0:37

I’ve given up on introducing you because we’ve done this so many times. Now, you don’t need an introduction any more. The first RFC I wanted to talk about a little bit this morning is the abstract trait methods validation RFC. What are traits?

Nikita 0:51

We usually talk about traits as compiler assisted copy and paste. Basically, we just take all the methods and properties from a trait and copy them into the class that’s using the trait. That’s a bit over simplified, in particular, you can use multiple traits in the single class. And those traits might be defining the same method, in which case you have to resolve the conflict in some way. So that’s where you have these insteadof or use annotations to specify precedents and aliases.

Derick Rethans 1:23

Traits has been in PHP for quite a long time. What is now the problem that you’re trying to solve through this RFC?

Nikita 1:29

The problem is that traits are sometimes not self contained. So to give a specific example, we have in the logger PSR, we have a trait called logger trait, which has a bunch of methods like warning, error, info, notice, and so on. So just simple helper methods, which all called the log method with a specific log level and this trait only specified these helper methods but still requires the actual class to implement the log method. The way you’ll usually indicate that is by adding an abstract method to the trait. You have all the methods you actually want to provide by the trait. And you have a number of abstract methods that the trait itself requires to work. This already works fine, but the problem is just that these methods are not actually validated, or they are only inconsistently validated. Even though the trait specifies this abstract methods, you could implement it in the class with a completely different signature.

Derick Rethans 2:30

Okay, just like any signature?

Nikita 2:32

Just like any signature right. The method still has to be present in some way. But the signature can be completely different. Could also be like different method type, like a static method, or an instance method.

Derick Rethans 2:43

Just basically checks for the name is what you’re saying?

Nikita 2:46

Yeah, it only checks with the name.

Derick Rethans 2:49

Is this the only place, is this the only time where these abstract methods are not being validated. Or are there other situations where that could happen as well?

Nikita 2:57

No, I think thi

Truncated by Planet PHP, read more at the original (another 25347 bytes)

Clustered Web Applications – Mysql and File replication – Alan Knowles

Article originally from rooJSolutions blog

In mid-2018, one of our clients asked if we could improve the reliability of their web applications. The system was developed by us and was hosted on a single server in Hong Kong. Over the last 5 years or so, the server had been sporadically unavailable due to various reasons

  • DDOS attack on the Hosting provider’s network
  • Hardware failure – both on the hosting machine and the provider’s network hardware.
  • Disk capacity issues


While most of these had been dealt with reasonably promptly, the service provided by our client to their customers had been down for periods up to a day. So we started the investigation into the solution to make this redundant and considerably more reliable.

the original (another 26317 bytes)

PHPun with FFI: Getting Rust-ic – platform.sh

So far in our FFI series, we’ve covered how to compile a C library and plug it into FFI on Platform.sh.
However, FFI doesn’t only work with C. It works with anything that can compile to the C ABI. Many languages can, although the best to use are those that do not have their own runtime or garbage collection as that can result in very odd mismatches when sharing data structures.

Curveball – A typescript microframework – Evert Pot

Curveball

Since mid-2018 we’ve been working on a new micro-framework, written in
typescript. The framework competes with Express, and takes heavy
inspiration from Koa. It’s called Curveball.

If you only ever worked with Express, I feel that for most people this
project will feel like a drastic step up. Express was really written in an
earlier time of Node.js, before Promises and async/await were commonplace,
so first and foremost the biggest change is the use of async/await middlewares
throughout.

If you came from Koa, that will already be familiar. Compared to Koa, these
are the major differences:

  • Curveball is written in Typescript
  • It has strong built-in support HTTP/2 push.
  • Native support for running servers on AWS Lambda, without the use of
    strange hacks.
  • Curveball’s request/response objects are decoupled from the Node.js http
    library.

At Bad Gateway we’ve been using this in a variety of (mostly API)
projects for the past few years, and it’s been working really well for us.
We’re also finding that it tends to be a pretty ‘sticky’ product. People exposed
to it tend to want to use it for their next project too.

Curious? Here are a bunch of examples of common tasks:

Examples

Hello world

import { Application } from '@curveball/core'; const app = new Application();
app.use( async ctx => { ctx.response.type = 'text/plain'; ctx.response.body = 'hello world';
}); app.listen(80);

Everything is a middleware, and middlewares may or may not be async.

Hello world on AWS Lambda

import { Application } from '@curveball/core';
import { handler } from '@curveball/aws-lambda'; const app = new Application();
app.use( ctx => { ctx.response.type = 'text/plain'; ctx.response.body = 'hello world

Truncated by Planet PHP, read more at the original (another 19676 bytes)

PHP Internals News: Episode 42: Userspace Operator Overloading – Derick Rethans

PHP Internals News: Episode 42: Userspace Operator Overloading

In this episode of “PHP Internals News” I chat with Jan Böhmer (GitHub, LinkedIn) about the Userspace Operator Overloading RFC.

The RSS feed for this podcast is https://derickrethans.nl/feed-phpinternalsnews.xml, you can download this episode’s MP3 file, and it’s available on Spotify and iTunes. There is a dedicated website: https://phpinternals.news

Transcript

Derick Rethans 0:16

Hi, I’m Derick. And this is PHP internals news, a weekly podcast dedicated to demystifying the development of the PHP language. This is Episode 42. Today I’m talking with Jan Böhmer about Userspace Operator Overloading. Jan, would you please introduce yourself?

Jan Böhmer 0:33

Hi, my name is Jan Böhmer. I’m a physics student from Germany. And I’m the author of the Operator Overloading RFC.

Derick Rethans 0:40

What brought you to writing this RFC?

Jan Böhmer 0:42

Mostly because I have worked with monetary objects in the past. And it was a bit tedious to work when it comes to calculating. And whenever you have to want to calculate something, you have to call functions on objects. This is not possible to call, just use operators like with normal values like floats or integers.

Derick Rethans 1:06

Because the monetary objects themselves had multiple things embedded in there or something like that?

Jan Böhmer 1:11

Yes, they describe mostly a value and a currency. And together they are saved in an object.

Derick Rethans 1:18

Okay that that seems like a reasonable thing to do, right? I mean, other times people say the same thing about doing complex numbers or something like vectors. The RFC is called Userspace Operator Overloading. What is operator overloading?

Jan Böhmer 1:31

Yeah. Basically, is the idea that you can define operators, like addition or subtraction, or the string concatenation for objects

Derick Rethans 1:43

Does PHP already have something like this?

Jan Böhmer 1:45

Actually, yes. Objects can have something that calls do operation handler. This is called whenever PHP encounters an object, but if used with an operator. The problem is that this handler is only available for PHP internally. So if you want to use it, you have to write an extension.

Derick Rethans 2:06

So it will be possible to have in an extension a Monetary class with its own operators already defined on it.

Jan Böhmer 2:14

Exactly PHP extension GMP uses this as already. The problem is that it’s not very flexible, you already have to know, be familiar with C, you have to be able to compile that. You have to contribute it to whatever system you want to use it. Since we have the foreign function interface since PHP 7.4 we can implement many things without to actually have an extension. But this operator overloading is something that’s not possible yet inside from PHP.

Derick Rethans 2:47

So it wouldn’t have been possible to write the GMP extension which is of course a wrap around libgmp with FFI, because there’s no operator overloading available in PHP.

Jan Böhmer 2:59

Not in that comfortable way. You could use this way with functions but it would a bit more tedious then using

Truncated by Planet PHP, read more at the original (another 13038 bytes)