26
3
submitted 4 months ago by lens0021@lemmy.ml to c/php@programming.dev
27
5

Setting up xdebug with swoole could be a bit of a hustle especially if application is containerized and you are running swoole and xdebug in a docker container with IDE on the host.

Here’s what worked for me.

Here I’m using hyperf framework, but I think issues and instructions should be similar for other swoole based frameworks (mezzio, resonance etc). Swoole 5.0.1 + PHP 8.1 natively support xdebug.

28
3
submitted 4 months ago* (last edited 4 months ago) by lens0021@lemmy.ml to c/php@programming.dev
29
5

I'm using 8.1/8.2 for production ...but I do have some pet projects in 8.4 that I might upgrade

30
-1
31
4

Cool article

32
11
submitted 5 months ago by skribe@piefed.social to c/php@programming.dev
33
8
PHP The Right Way (www.youtube.com)

Ohh yeah, good old days when we had to ftp/sftp into the server to upload the PHP files.

I recommend subscribing to his channel.

34
6
submitted 7 months ago by rikudou@lemmings.world to c/php@programming.dev

cross-posted from: https://chrastecky.dev/post/16

Starting with PHP 8.5, you'll be able to do the following:

 public function __construct(
    final public string $someProperty,
) {}

This wasn't possible before, as promoted properties couldn't be declared final.

Perhaps the more interesting part is that you can now omit the visibility modifier if you include final. In that case, the property will default to public:

 public function __construct(
    final string $someProperty, // this property will be public
) {}

Personally, I’m not a fan of this behavior — I prefer explicit over implicit. Fortunately, it can be enforced by third-party tools like code style fixers. Still, I would have preferred if the core required the visibility to be specified.

What do you think? Do you like this change, or would you have preferred a stricter approach?

35
13
submitted 7 months ago by rikudou@lemmings.world to c/php@programming.dev

cross-posted from: https://chrastecky.dev/post/13

This change is quite straightforward, so this won’t be a long article. PHP 8.5 adds support for annotating non-class, compile-time constants with attributes. Compile-time constants are those defined using the const keyword, not the define() function.

Attributes can now include Attribute::TARGET_CONSTANT among their valid targets. Additionally, as the name suggests, Attribute::TARGET_ALL now includes constants as well. The ReflectionConstant class has been updated with a new method, getAttributes(), to support retrieving these annotations.

One particularly useful aspect of this change is that the built-in #[Deprecated] attribute can now be applied to compile-time constants.

As promised, this was a short post, since the change is relatively simple. See you next time—hopefully with a more exciting new feature in PHP 8.5!

36
11
submitted 7 months ago by rikudou@lemmings.world to c/php@programming.dev

cross-posted from: https://chrastecky.dev/post/15

PHP has long had a levenshtein() function, but it comes with a significant limitation: it doesn’t support UTF-8.

If you’re not familiar with the Levenshtein distance, it’s a way to measure how different two strings are — by counting the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one string into another.

For example, the following code returns 2 instead of the correct result, 1:

var_dump(levenshtein('göthe', 'gothe'));

There are workarounds — such as using a pure PHP implementation or converting strings to a custom single-byte encoding — but they come with downsides, like slower performance or non-standard behavior.

With the new grapheme_levenshtein() function in PHP 8.5, the code above now correctly returns 1.

Grapheme-Based Comparison

What makes this new function especially powerful is that it operates on graphemes, not bytes or code points. For instance, the character é (accented 'e') can be represented in two ways: as a single code point (U+00E9) or as a combination of the letter e (U+0065) and a combining accent (U+0301). In PHP, you can write these as:

$string1 = "\u{00e9}";
$string2 = "\u{0065}\u{0301}";

Even though these strings are technically different at the byte level, they represent the same grapheme. The new grapheme_levenshtein() function correctly recognizes this and returns 0 — meaning no difference.

This is particularly useful when working with complex scripts such as Japanese, Chinese, or Korean, where grapheme clusters play a bigger role than in Latin or Cyrillic alphabets.

Just for fun: what do you think the original levenshtein() function will return for the example above?

var_dump(levenshtein("\u{0065}\u{0301}", "\u{00e9}"));
37
2
PHP 8.3.22 (www.php.net)
submitted 8 months ago* (last edited 8 months ago) by cm0002@lemmy.world to c/php@programming.dev
38
3
PHP 8.4.8 (www.php.net)
submitted 8 months ago by cm0002@lemmy.world to c/php@programming.dev
39
5
40
2
submitted 9 months ago by cm0002@lemmy.world to c/php@programming.dev
41
5
PHP 8.4.7 Released! (www.php.net)
submitted 9 months ago by cm0002@lemmy.world to c/php@programming.dev
42
3

June 17, 2025

  • 13:30–19:00 CET/CEST
  • 07:30–13:00 EST/EDT
  • 11:30–17:00 UTC
43
4
submitted 10 months ago by danb@feddit.uk to c/php@programming.dev

Internals link: https://externals.io/message/127120

Note: I am not the RFC author.

44
7
submitted 10 months ago by danb@feddit.uk to c/php@programming.dev

Note: I am not the RFC author.

45
3
46
9
47
6
submitted 1 year ago by nettie@lemmy.world to c/php@programming.dev

I noticed that if you have too few pm_children set then some requests hang until timeout. This surprised me - I'd expect an immediate error, but it's more like a tarpit! For ages I was thinking my server was not performant, then I noticed via top that it wasn't doing or waiting while the browser was.

I have two questions:

  1. If you have pm_max_children=1 and you occupy that and submit another request, what actually happens? (I'm proxying through nginx.) HTTP doesn't have a "40_ Come back later".

  2. (if life deals you lemons...) if you can generate a tarpit that doesn't use server resources, this could be quite useful to know about too!

48
2
submitted 1 year ago by Fitik@fedia.io to c/php@programming.dev

A summary of the highlights and key accomplishments of the Symfony project in 2024.

49
14
submitted 1 year ago* (last edited 1 year ago) by Olissipo@programming.dev to c/php@programming.dev

My TLDR is:

  • Their team was using PHP

  • Before doing a complete re-write they evaluated other languages

  • Rust ruled out due to cost/benefit, being the fastest in the list, but also the most complex

  • PHP kept as the main language because:

    • The ecosystem is mature
    • The PHP/Symfony (and Roadrunner) stack meets their high-performance needs
  • Inertia: their team "already had extensive experience" in it

  • They already integrated Go in some microservices

  • They aren't locked to PHP, and will continue to evaluate these programming languages and others

50
74

Ever wanted to provide your arguments to a function as a comment?

https://gist.github.com/RikudouSage/18defbf1746322a289ae78b2980d0115

#php #cursed #wtf #programming @php

view more: ‹ prev next ›

PHP

778 readers
1 users here now

Welcome to /c/php! This is a community for PHP developers and enthusiasts to share and discuss anything related to PHP. From the latest updates and tutorials, to your burning questions and amazing personal projects, we welcome all contributions.

Let's foster an environment of respect, learning, and mutual growth. Whether you're an experienced PHP developer, a beginner, or just interested in learning more about PHP, we're glad to have you here!

Let's code, learn, and grow together!

founded 2 years ago
MODERATORS