How to check which version of PHP you are running
When working on open source code, I like using the latest version of PHP. When developers that are not on the latest version use the package, they might see syntax errors.
You might ask why Composer doesn't protect against this? When composer.json requires the latest version, how do devs, not on the latest version, can even install the package?
Well, there seemingly are a lot of people that only upgrade the PHP version on the command line. For handling web requests, they are unknowingly using an older version of PHP. Here's how to make sure you are on the latest version of PHP on both the CLI and for handling web requests.
On the CLI type this command to see your PHP version:
php -v
To check the PHP version that handles web requests, create a .php
file with this content somewhere the public directory of your app.
<?php
phpinfo();
Point your browser to that file. You will now see which version of PHP you are running. Don't forget to delete the file afterward.
What are your thoughts on "How to check which version of PHP you are running"?