Is opcache_reset supposed to work on windows? - php

Enviroment wamp on windows, PHP version 7.4
The result of opcache_get_status after calling opcode_reset shows
opcache_enabled => false
restart_pending => 1
This goes on for a long time and no actual restart is happening, and the manual restart count still shows 0.
Is this a specific windows gotcha thing, or I should look for some misconfiguration (where?)

I set up a WSL2 enviroment on the same machine and opcache_reset behaves as expected, so it must be just another way in which php behaves differently on linux and windows.

Related

die() is not stopping code from executing

the problem is in the following:
echo 'Hello...';
die('I died...');
echo 'HAHAHA!!!';
on the web browser it is executing the echo after the die().
on the CLI stops on the die() and does not shows the echo as expected.
My Specs:
PHP 7.4 (FPM)
web server Nginx (also tried with apache with the same result)
Also I had a time long a test server on windows and it was exiting the script when exit or die was called, but somehow on the debian test server is not doing that.
is there something I am missing?
do you guys have any tip?
Thanks in advance....
Update on 2022-07-27 :
script:
Browser output:
CLI output
I've updated the PHP version (same happening):
#MarkusZeller yes is disabled the opcache:
still not working...
but somehow on the windows server under php7.4.26 runs the script with the expected die
The development environment is windows with Debian 11 (WSL2) I have also tried it yesterday on a test machine I have in my home with base Debian 11 installed and it has the same issue. Same thing with the Debian 11 test server at work.
#YourCommonSense the script is the same. Here is the nginx path config:
Solution:
The cause of the problem was on the extension php-uopz. After installing every extension individually and testing after every install, the behavior only happens after this extension is activated. Hope this helps in case anyone runs into the same issue.

Check if PDFTOHTML is installed on server

I'm trying to check before running a php script if pdftohtml is installed on server.
Is there a way to check if pdftohtml is installed on server (linux or mac) from within the code.
I'm looking for something similar to function_exists()
Perhaps, the following will solve your case:
$isInstalled = (bool) shell_exec('which pdftohtml');
which returns nothing if the program isn't found. But it will only work if it's installed globally (without specifying an absolute path). And returns a full path if it's there

Can't Run PHP Imagick from Command Line?

I realize that Imagick has it's own command line executables, but why whenever I try to run an Imagick command written in PHP it breaks my script and exits without warning?
Take something simple:
<?php
$imagepath = realpath('1.gif');
var_dump('111');
$image = new Imagick($imagepath);
var_dump('222');
var_dump($image);
Running php -f imagick.php on my command line interface just simply outputs string(3) "111" and then immediately exits once it hits any Imagick function.
Imagick is properly installed on my machine, and if I do a php -m it shows Imagick as an installed module.
Is there anyway to get it working in command line scripts (aside from using exec())?
I was slightly worried that it wouldn't work on cron jobs, but I just did a quick test and it seems to be working within that (least on VPS).
Am trying from Windows x64 WAMP server PHP v7.1.16.
Note: To clarify, this is just a command line issue. Imagick is installed correctly, no issue with syntax, I've been using it for months in the browser with no issues.
Even command line attempts.. php -d display_errors imagick.php, same, dies upon impact of IM with no notice php -n -l -d display_errors -d display_startup_errors imagick.php brings back 'No Syntax Errors'. It's peculiar, nothing should simply kill the script (although it does try to load for a second before it essentially breaks out of the script no matter where it's at) without any notice.. then again since there's no issue running it in the browser over and over, so I don't think there is any errors (especially sampling my above one liner Imagick initalization).. it's just a CLI thing that I do not understand.
This was a local issue, apparently.
I recently reinstalled Windows and subsequently reinstalled Imagick and PHP.
Anyone else having similar issues I recommend reinstalling Imagick (it's a big pain to install -- recommend using these references for installing on a Windows 10 machine:
Installing Imagick for PHP 7 on Windows 10
Proper Way to CLI PHP within WAMP (WAMP64), while switching between Multiple PHP Versions on Windows 10
Also I've yet to try this personally, but by the looks of it, seems a better method for imagick integration with PHP: ImageMagickPHP (Imagick PHP Class that utilizes command line exec as opposed to the PHP version).

XAMPP not interpreting PHP code + Errors

First things first, when I open and run XAMPP this shows up
The issue is, when I try and open a .php file it doesn't work it simply just shows the code WITHIN the php file, the php itself does not work.
I have downloaded and uninstalled XAMPP 3 times today.
Any ideas?
This is a rookie mistake, Make sure the URL says localhost/index.php and not file:///C:/...
To fix the problem you need to change xampp port from 80. Normaly 81 works just fine.
Follow these steps to change the XAMPP server port number:
1) Stop the XAMPP server, if it is running already.
2) Open the file [XAMPP Installation Folder]/apache/conf/httpd.conf.
3) Search for: "Listen 80"
4) Change to (Example): "Listen 81"
5) Search : ServerName (Update this too)
6) Save
7) Restart XAMPP server and you are done.
Note:
Now your url is: www.localhost:81
You should just try reinstalling the operating system as well as xampp over again. My answer takes into consideration that you have already tried installing xampp three times. If you have a Mac just restart holding the command and r keys and then wait for the recovery center to come up. Then select reinstall osx. This requires internet. If you have windows there might be an install disk that came with the system and try reinstalling from the disk.
Problem is that port 80 is being used by some other application. If you have installed skype it would skype. We can manually change the port used by skype for that check the answer for this SO question How to solve WAMP and Skype conflict on Windows 7?
You can also make sure which appication is using port 80 by checking this SO question How to find which program is using port 80 in Windows?

PHP-cgi stops working randomly without error log

I'm using nginx with (WT-NMP - portable mysql nginx php app.). Everything is working perfectly except php-cgi, it is stopping randomly and i have to start it again, in fact i realized that if i add to post my website quickly (in wordpress), it is definitely stopping. But sometimes it is stopping without for no reason, maybe there is a reason but i cant see because no error shows in errorlogs.
I searched on the internet and I found something about my problem but I couldn't use these methods on my windows server.
The solution I found: SET PHP_FCGI_MAX_REQUESTS=0 to the script that starts php-cgi.exe
#ECHO OFF
ECHO Starting PHP FastCGI...
SET PHP_FCGI_MAX_REQUESTS=0
SET PATH="D:\Program Files\php;%PATH%"
"C:\Program Files\php\php-cgi.exe" -b 127.0.0.1:9000 -c "C:\Program Files\php\php.ini"
Any idea about my problem? or any idea how to use this codes on my windows server. I searched for windows and found only one solution, it was about the IIS.
The proccess: adding PHP_FCGI_MAX_REQUESTS=0 to environment variables.
The following setting works fine for Windows 2012 R2 Server !!!
http://i.stack.imgur.com/HrIaO.jpg
Control Panel-> System->Advanced System Settings->Advanced->Environment Variables->System Variables-> New -> Variable Name: PHP_FCGI_MAX_REQUESTS & Variable Value: 0

Categories