PHPCompatInfo – Check the minimum requirement of your php code

- Development, PHP, Resources

PHPCompatInfo is a powered tool that analysis a folder with php files and report about the minimum version of php runtime required.

Very useful for test a project before the release on production!

How to install

wget http://bartlett.laurent-laville.org/get/phpcompatinfo-3.2.0.phar

mv phpcompatinfo-3.2.0.phar /usr/local/bin/phpcompatinfo

chmod +x /usr/local/bin/phpcompatinfo

After this in your project folder is required a phpcompat.json file, this file contain the plugin used for check the code, the path and other info. This is an example complete with all the plugin.

After this you can use this fantastic tool!

phpcompatinfo analyser:run . –php=”>= 5.2″

Documentation?

The developers of this project have written a complete documentation on http://php5.laurent-laville.org/compatinfo/manual/3.2/en/getting-started.html

Example

Data Source Analysed

Directories                                         28
Files                                                   50

Summary Analysis

Summary
Extensions                                          6
Namespaces                                       1
Interfaces                                            0
Traits                                                   0
Classes                                               39
Methods                                          299
Functions                                          27
Constants                                          31
Internal Functions                            79

Versions
PHP min                                          5.2.0
PHP max

Why the PHP min 5.2 in this example?

In PHP 5.3 has been added support for the anonymous function and WordPress minimum requirement is PHP 5.2.
If you want create a plugin for WordPress that have a big support need to support PHP 5.2.

PS: I use Debian Sid for the development, PHP 5.6 RC3. Yeah! Yes i like the development version, and i have never noticed about this minimum requirement of WordPress until someone opened a ticket.

Conclusion

This is a new tool for my PHP swiss knife with other:

  • PHP CodeSniffer
  • PHP CodeSniffer Fixer
  • PHP MD
  • PHP Unit
  • XDebug
  • Apigen
  • Composer
  • WP CLI
  • Wordmove
  • WP Scan
  • Netbeans
  • My Brain – this is not on Github

PS: Netbeans i want an integration for this. I warned you 😀

Liked it? Take a second to support Mte90 on Patreon!

Become a Patreon
All the stuff released in this website, where the author is Daniele Scasciafratte, is under the GPL 2.0 license except when the resources have their licenses.

Leave a Reply