I am running Windows 10 latest version and VsCode latest version. I'm setting up a website using a PHP framework. Natively there seems no formatting support for PHP so I turned to plugins. I tried 'Format HTML in PHP' and that does exactly what it says - a page of HTML in a file with a .php extension is formatted on save. However when I try to format say a Controller, either on save or by pressing Alt-Shift-F, absolutely nothing happens. I have tried installing 'PHPfmt', 'PHP Intelephense, and 'Prettier' but in each case any attempt to format the Controller (Alt-Shift-F) failed to change anything. Yes I did restart the editor in every case. Can anyone suggest why this is not working or a plugin better than the ones I have tried? Is 'Format HTML in PHP' incompatible with the other plugins? I have really spent a long time on this and got nowhere.
How to "guess" php version by looking at code?
Suppose you're handed a zip file containing php code for an application.
Are there any telltale signs about which version (5.x, 7.1, 7.3,etc )
the original author was working with?
My issue is, I suspect I'm running an incorrect php version for my (phalcon) application, my users can't log in. I see in logs
"PHP Warning: Use of undefined constant success - assumed 'success' (this will throw an Error in a future version of PHP)"
and
Uncaught Error: Class 'View' not found in ....
In general, this is not possible. You can inspect the set of features the original author used and try to identify a minimal version. When you find removed features you can also find a maximum version.
According to your warning message I assume you are using PHP 7.2 right now?!
The author probably developed this with a lower version (5.x) or has disabled warnings.
Maybe have a look here for more info about your warning message.
However, the warnings and errors you get are not really version related but seem to result from missing files and / or bad programming.
You should try to make it work with Version 7.2+ instead of choosing the version matching the developers version. Have a look at PHP versions here.
I have a large number of source files where I have made use of various newer PHP features - in particular binary numbers, short array syntax, function array dereferencing, and finally blocks.
With the exception of the latter it seems to me that these would be fairly trivial to write a tool to automatically downgrade (assuming no insanity like usage of eval) the code and in fact if I'm unable to find any then I think I will basically have to.
Still, the reason that I have ended up in this position is because I am new to the language in the first place so just because I couldn't find anything (other than php -l) doesn't mean that such a tool doesn't exist. Does anyone know of one?
I've just published a tool to convert PHP 5.4+ code into PHP 5.3 compatible: https://github.com/endel/php-code-downgrade
It's mainly based upon igorw/galapagos and nikic/PHP-Parser projects. So don't thank me, thank them! ;)
I work on an open-source tool that handles instant upgrades but also instant downgrades.
From PHP 8.0 to PHP 5.4 - it's called Rector: http://github.com/rectorphp/rector
We eat our own dog food... :) Rector itself is developed in PHP 7.3 and code downgraded to PHP 7.1:
root composer.json with PHP 7.3+
release composer.json with PHP 7.1+
This is the error every time I start up php:
Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20100525/proxyauth.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20100525/proxyauth.so, 9)
I have two older versions of the proxyauth.so in no-debug-non-zts-20060613 and no-debug-non-zts-20090626, but neither is compatible with a module API compatible with 20100525, so symlinking doesn't solve the problem.
I've Googled my best and have no idea where proxyauth comes from, and therefore can't make a new one with the compatible API. There doesn't appear to be an extension in the php ext directory, so I have no idea what to do next.
Thoughts?
Thanks,
Bill
If the warning is the only problem - meaning your code itself runs fine - then the extension isn't required anymore by your application. Why not out-commenting the extension=proxyauth.so?
I have an inconsistency, and I could not align their versions properly, so I just wanted to remove the library version. Can I do this? Is the header version for PHP while the library is from my distro? Can I upgrade PHP's library version? If so, how? I am using PHP 5.4.4
For example,
Is the header version for PHP while the library is from my distro?
It means it was compiled against the 1.0.1 headers, but is now dynamically linking against 0.9.8. So you are using an older version than what was used when PHP was compiled.
Many libraries store the version in the header files. So when a program uses the library, it can do something like int HEADER_FOO_VERSION = LIBRARY_VERSION, which embeds that version number into the program (e.g., php). Now when that program runs, it links dynamically against the library, which may be a different one than was on the host system.
That library may have a function call, say int get_library_version(). So the program (PHP) can check if HEADER_FOO_VERSION == get_library_version(). If it's different, then there could be a compatibility issue. (Of course, it doesn't have to be assign to a local variable... I'm just trying to drive home the point that the header version number can be compiled into php, and remains constant no matter which version of the library is being used at run time.)
Whether or not it is a problem depends on if the two versions are compatible.
Usually if the library is > than the header, you are okay. It's definitely more likely to be a problem if the library is older than the version it was linked against. Of course, this is because it's impossible to know what changes future versions may have.
So in your case, I would try to update your system's SSL libraries via apt-get, yum, etc, to match the version PHP is expecting.
To check which version php is using on Linux:
$ ldd `which php` | grep ssl
libssl.so.1.0.0 => /lib/i386-linux-gnu/libssl.so.1.0.0
Note that which php is just a short-cut to find the full path. You can hard code any executable you'd like to check: ldd /usr/sbin/httpd.
I dont know the answer myself, but when searched on google some nice resources explaining the same.....
What's the difference between a header file and a library?
The version of the files are the one mentioned in the phpinfo used to create a library.
Hope it helps, there are lot of resource available if searched on google.
Still will like to hear from someone in great details about the question
The header version is the functionality version, whereas the library version is the code version.
The header defines the interface - it tells you what functions are within the library. If a header gets updated, then you need to check to make sure all the functions are the same, and see if any are added or subtracted.
But if a library gets updated, and not the header, it means all the function calls are the same, but some of the code may be changed (eg, bug fixes).
In your example, PHP is seeing functionality for OpenSSL 1.0.1, but the actual version of the source code that OpenSSL is loading is 0.9.8o
This is commonly seen on updated versions of openssl. What happens is the newer versions for the libraries are stored in different folder. The original folder located at /usr/bin/openssl would need a symbolic link to the new folder /usr/local/bin/openssl. That would get both to be the same version or just show OpenSSL Version _(Whatever)
Normally there is no concern for this, since it still works the way it is intended. This is seen a lot on shared servers.
EDIT:
The information in this post is generic and can be different if you are running
CentOS, RedHat, Ubuntu, or another Linux/BSD version. Check documentation or man
pages for the best information
If you do update your OpenSSL, some versions of *nix Require for you to rebuild PHP and Apache for it to update
If you are rebuilding PHP from source, I have found another possible reason for a mismatch. It's so simple yet if you are not familiar with building from source on Linux, not knowing it can cost you a lot of time.
The answer is here: https://serverfault.com/a/567705/305059 - unfortunately I cannot up-vote it over the not-so-useful answer, so if you have the reputation there, please do.
You need to run "make clean" before "make" in order for it to rebuild all binaries. Strangely, without this step I was getting an updated library version, but the old header version - so I think it must have rebuilt something, but not everything. My rebuild involved linking to a version of curl in another location (built with ssl), which might be the reason behind it.
Anyway, I hope this helps someone. Thank you to #velcrow on serverfault.