Choosing between thread-safe and non-thread-safe PHP: how to make the right decision?
P粉350036783
P粉350036783 2023-12-23 23:34:59
0
1
594

I'm developing a Laravel 9.x application in Windows 10. My current PHP version is PHP 8.1.5 (cli) (build: Apr 12 2022 17:38:57) (ZTS Visual C 2019 x64) . Is this a thread-safe version or a non-thread-safe version? how could I know? When should I choose the thread-safe version over the non-thread-safe version?

I tried researching this question on StackOverflow, but the questions/answers I saw seemed to be a decade or more old - something like this - and I strongly suspect that if I asked this question today, I'd probably get a different The answer is simply because technology has changed over the years. Is this a reasonable assumption? (At least, my current version of PHP apparently uses the newer compiler VC 2019, not VC6 or VC9.)

I don't know yet what my production environment will look like, or even if the application I'm developing will ever make it to production, since it's just an application I'm writing to (re)learn Laravel. I'll probably put this into production at some point as a demo for a Laravel app, but whether it will be on a hosting service, Netlify or something else, I don't know yet.

Just to give you some background, this question only came up because I was trying to learn how to step through Laravel source code to debug an issue, which obviously required me to add XDebug to XAMPP. The instructions I found for installing XDebug pointed me here and suggested that I download the Windows binaries for my version of PHP. There are no binaries for 8.1.5, so I don't know if one of the binaries for 8.1 will work, or if I'm better off using 8.1 thread-safe or 8.1 non-thread-safe. It would be better if my PHP was upgraded to 8.2 first, I still don't know if thread-safe or non-thread-safe is the better choice.

Can someone tell me these questions?

P粉350036783
P粉350036783

reply all(1)
P粉033429162

Is this a thread-safe version or a non-thread-safe version? how could I know?

You can use the old phpinfo() function and look for the Thread Safety column.

If you have PHP set up in your PATH environment, you can even get it via the CLI using the quick command php -i | grep thread

When should I choose the thread-safe version over the non-thread-safe version?

According to PHP official documentation

I don’t know yet what my production environment will look like...

In general, there is no difference in TS or NTS code execution. It's more web server oriented.

If I remember correctly, XAMPP uses Apache Handler by default, so it is probably a thread-safe build. Yes, the Xdebug binaries for PHP8.1 work fine.

Technically, NTS should be slightly faster since it doesn't need to consider thread safety.

Personally I don't think it matters unless you want to spend more time tinkering with the webserver, switch to FastCGI or PHP-FPM since you are still in the development phase, I think stick with the default settings and It’s more efficient to focus on getting it done.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template