PHP Classes

PHP Code Analyzer: Analyze PHP code to check if it uses extensions

Recommend this page to a friend!
  Info   View files Documentation   View files View files (137)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2023-01-18 (2 days ago) RSS 2.0 feedStarStarStarStar 73%Total: 304 This week: 4All time: 7,347 This week: 42Up
Version License PHP version Categories
phpca 1.13BSD License5.3PHP 5, Utilities and Tools, Language
Description Author

This class can analyze PHP code to check if it uses non-builtin extensions.

It can take the path of a given PHP source file or directory and parses the source files to find out calls to known functions, classes or constants defined by those PHP extensions.

The class can output a report that tells what PHP extensions are used in the code, denoting if each extension is bundled with PHP or not, the first and last versions of PHP the extension was made available, if the extension development is dead, if it is available in PECL repository or if it is a Windows specific extension.

The information about the detected extensions is read for a separate data directory that can be updated with information about other extensions not yet detected.

Innovation Award
PHP Programming Innovation award nominee
June 2015
Number 8


Prize: One book of choice by Packt
Over the years many developers have worked on code that now may be considered legacy.

Some code relies on PHP extensions that existed in past PHP versions but may not be available in future versions.

This package is a tool that can examine your PHP code and tell which extensions it relies, as wel in which PHP versions those extensions are supported.

Manuel Lemos
Picture of Sergey Vanyushin
  Performance   Level  
Name: Sergey Vanyushin <contact>
Classes: 15 packages by
Country: Russian Federation Russian Federation
Innovation award
Innovation award
Nominee: 15x

Winner: 2x

Details

PhpCodeAnalyzer

PhpCodeAnalyzer finds usage of different non-built-in extensions in your php code. This tool helps you understand how transportable your code between php installations is.

Latest Stable Version Total Downloads License

TOC

Example of usage

To scan your files or folder launch phpca and pass file or directory names.

> phpca ..\HttpServer
Scanning ..\HttpServer ...
[spl] Function "spl_autoload_register" used in file ..\HttpServer/vendor/composer/ClassLoader.php[258]
[spl] Function "spl_autoload_unregister" used in file ..\HttpServer/vendor/composer/ClassLoader.php[266]
[spl] Function "spl_autoload_register" used in file ..\HttpServer/vendor/composer/autoload_real.php[22]
[spl] Function "spl_autoload_unregister" used in file ..\HttpServer/vendor/composer/autoload_real.php[24]

Used non-built-in extensions in your code:
- [spl] Standard PHP Library (SPL). This extension is bundled with php since PHP 5.0.0. Extension is available in pecl: spl.

You can skip progress with --no-progress option:

> phpca --no-progress ..\yii-1.1.16.bca042\framework\caching
Scanning ..\yii-1.1.16.bca042\framework\caching ...

Used non-built-in extensions in your code:
- [apc] Alternative PHP Cache. Extension is available in pecl: apc.
- [wincache] Windows Cache for PHP. Extension is available in pecl: wincache.

Also, you can keep only progress with --no-report option:

> phpca --no-report ..\yii-1.1.16.bca042\framework\caching
Scanning ..\yii-1.1.16.bca042\framework\caching ...
[apc] Function "apc_fetch" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[46]
[apc] Function "apc_fetch" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[56]
[apc] Function "apc_store" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[70]
[apc] Function "apc_add" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[84]
[apc] Function "apc_delete" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[95]
[apc] Function "apc_clear_cache" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[107]
[apc] Function "apc_clear_cache" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[109]
[wincache] Function "wincache_ucache_get" used in file ..\yii-1.1.16.bca042\framework\caching/CWinCache.php[46]
[wincache] Function "wincache_ucache_get" used in file ..\yii-1.1.16.bca042\framework\caching/CWinCache.php[56]
[wincache] Function "wincache_ucache_set" used in file ..\yii-1.1.16.bca042\framework\caching/CWinCache.php[70]
[wincache] Function "wincache_ucache_add" used in file ..\yii-1.1.16.bca042\framework\caching/CWinCache.php[84]
[wincache] Function "wincache_ucache_delete" used in file ..\yii-1.1.16.bca042\framework\caching/CWinCache.php[95]
[wincache] Function "wincache_ucache_clear" used in file ..\yii-1.1.16.bca042\framework\caching/CWinCache.php[106]

If you want to see only usage of one specific extension, use --extension= option:

> phpca --extension=apc ..\yii-1.1.16.bca042\framework\caching
Scanning ..\yii-1.1.16.bca042\framework\caching ...
[apc] Function "apc_fetch" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[46]
[apc] Function "apc_fetch" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[56]
[apc] Function "apc_store" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[70]
[apc] Function "apc_add" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[84]
[apc] Function "apc_delete" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[95]
[apc] Function "apc_clear_cache" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[107]
[apc] Function "apc_clear_cache" used in file ..\yii-1.1.16.bca042\framework\caching/CApcCache.php[109]

Summary report in this case will not be added at the end.

Help

Full list of available options:

> phpca -h
PhpCodeAnalyzer
Usage:
    phpca [-v] [-q] [--output=<path>] [--no-report] [--no-progress] [--since-version=<version>] FILES...
    phpca [-v] [-q] [--output=<path>] --extension=<ext> FILES...
    phpca -h

Options:
  -h --help                 Show this text
  -v --verbose              Show more debug text
  -q --quiet                Don't print any messages
  --output=<path>           Path where to generate XML report
  --extension=<ext>         Look for usage a specific extension
  --no-report               Turn off summary report
  --no-progress             Turn off progress
  --since-version=<version> Only include extensions not included since version

Installation

Phar

  1. Just download a phar from releases page and make executable
    chmod +x phpca.phar
    
  2. a. Local installation: use it from current folder:
      ./phpca.phar -h
    
      b. Global installation: move it in to one of folders listed in your `$PATH` and run from any folder:
    
    sudo mv phpca.phar /usr/local/bin/phpca phpca -h

Composer

Another way to install phpca is via composer.

  1. Install composer:
    curl -sS https://getcomposer.org/installer | php
    
  2. Install phpcf in global composer dir:
    ./composer.phar global require wapmorgan/php-code-analyzer dev-master
    
  3. Run from any folder:
    phpca -h
    
  Files folder image Files  
File Role Description
Files folder imagebin (1 file)
Files folder imagedata (131 files)
Files folder imagesrc (1 file)
Plain text file composer.json Data Auxiliary data
Plain text file LICENSE.md Lic. Auxiliary data
Plain text file README.md Doc. Auxiliary data
Plain text file _config.yml Data Auxiliary data

  Files folder image Files  /  bin  
File Role Description
  Plain text file phpca Example Auxiliary data

  Files folder image Files  /  data  
File Role Description
  Plain text file apc.php Aux. Auxiliary script
  Plain text file apd.php Aux. Auxiliary script
  Plain text file bbcode.php Aux. Auxiliary script
  Plain text file bcompiler.php Aux. Auxiliary script
  Plain text file blenc.php Aux. Auxiliary script
  Plain text file cairo.php Aux. Auxiliary script
  Plain text file chdb.php Aux. Auxiliary script
  Plain text file classkit.php Aux. Auxiliary script
  Plain text file com.php Aux. Auxiliary script
  Plain text file crack.php Aux. Auxiliary script
  Plain text file cubrid.php Aux. Auxiliary script
  Plain text file curl.php Aux. Auxiliary script
  Plain text file dba.php Aux. Auxiliary script
  Plain text file dbplus.php Aux. Auxiliary script
  Plain text file dbx.php Aux. Auxiliary script
  Plain text file dio.php Aux. Auxiliary script
  Plain text file eio.php Aux. Auxiliary script
  Plain text file enchant.php Aux. Auxiliary script
  Plain text file ev.php Aux. Auxiliary script
  Plain text file event.php Aux. Auxiliary script
  Plain text file expect.php Aux. Auxiliary script
  Plain text file fam.php Aux. Auxiliary script
  Plain text file fann.php Aux. Auxiliary script
  Plain text file fdf.php Aux. Auxiliary script
  Plain text file fileinfo.php Aux. Auxiliary script
  Plain text file filter.php Aux. Auxiliary script
  Plain text file fribidi.php Aux. Auxiliary script
  Plain text file gearman.php Aux. Auxiliary script
  Plain text file gender.php Aux. Auxiliary script
  Plain text file geoip.php Aux. Auxiliary script
  Plain text file gmagick.php Aux. Auxiliary script
  Plain text file gnupg.php Aux. Auxiliary script
  Plain text file gupnp.php Aux. Auxiliary script
  Plain text file haru.php Aux. Auxiliary script
  Plain text file hash.php Aux. Auxiliary script
  Plain text file hrtime.php Aux. Auxiliary script
  Plain text file http.php Aux. Auxiliary script
  Plain text file hwapi.php Aux. Auxiliary script
  Plain text file ibm-db2.php Aux. Auxiliary script
  Plain text file id3.php Aux. Auxiliary script
  Plain text file iisfunc.php Aux. Auxiliary script
  Plain text file imagick.php Aux. Auxiliary script
  Plain text file inclued.php Aux. Auxiliary script
  Plain text file ingres.php Aux. Auxiliary script
  Plain text file inotify.php Aux. Auxiliary script
  Plain text file intl.php Aux. Auxiliary script
  Plain text file json.php Aux. Auxiliary script
  Plain text file judy.php Aux. Auxiliary script
  Plain text file kadm5.php Aux. Auxiliary script
  Plain text file ktaglib.php Aux. Auxiliary script
  Plain text file lapack.php Aux. Auxiliary script
  Plain text file libevent.php Aux. Auxiliary script
  Plain text file lua.php Aux. Auxiliary script
  Plain text file lzf.php Aux. Auxiliary script
  Plain text file mailparse.php Aux. Auxiliary script
  Plain text file mcve.php Aux. Auxiliary script
  Plain text file memcache.php Aux. Auxiliary script
  Plain text file memcached.php Aux. Auxiliary script
  Plain text file mhash.php Aux. Auxiliary script
  Plain text file ming.php Aux. Auxiliary script
  Plain text file mnogosearch.php Aux. Auxiliary script
  Plain text file mongo.php Aux. Auxiliary script
  Plain text file mqseries.php Aux. Auxiliary script
  Plain text file msession.php Aux. Auxiliary script
  Plain text file ncurses.php Aux. Auxiliary script
  Plain text file net-gopher.php Aux. Auxiliary script
  Plain text file newt.php Aux. Auxiliary script
  Plain text file nis.php Aux. Auxiliary script
  Plain text file oauth.php Aux. Auxiliary script
  Plain text file odbc.php Aux. Auxiliary script
  Plain text file oggvorbis.php Aux. Auxiliary script
  Plain text file opcache.php Aux. Auxiliary script
  Plain text file openal.php Aux. Auxiliary script
  Plain text file paradox.php Aux. Auxiliary script
  Plain text file parsekit.php Aux. Auxiliary script
  Plain text file pdf.php Aux. Auxiliary script
  Plain text file pdo.php Aux. Auxiliary script
  Plain text file proctitle.php Aux. Auxiliary script
  Plain text file ps.php Aux. Auxiliary script
  Plain text file pthreads.php Aux. Auxiliary script
  Plain text file quickhash.php Aux. Auxiliary script
  Plain text file radius.php Aux. Auxiliary script
  Plain text file rar.php Aux. Auxiliary script
  Plain text file readline.php Aux. Auxiliary script
  Plain text file rpmreader.php Aux. Auxiliary script
  Plain text file rrd.php Aux. Auxiliary script
  Plain text file runkit.php Aux. Auxiliary script
  Plain text file sam.php Aux. Auxiliary script
  Plain text file sca.php Aux. Auxiliary script
  Plain text file sdo.php Aux. Auxiliary script
  Plain text file session-pgsql.php Aux. Auxiliary script
  Plain text file snmp.php Aux. Auxiliary script
  Plain text file soap.php Aux. Auxiliary script
  Plain text file solr.php Aux. Auxiliary script
  Plain text file sphinx.php Aux. Auxiliary script
  Plain text file spl-types.php Aux. Auxiliary script
  Plain text file spl.php Aux. Auxiliary script
  Plain text file spplus.php Aux. Auxiliary script
  Plain text file sqlsrv.php Aux. Auxiliary script
  Plain text file ssdeep.php Aux. Auxiliary script
  Plain text file ssh2.php Aux. Auxiliary script
  Plain text file stats.php Aux. Auxiliary script
  Plain text file stomp.php Aux. Auxiliary script
  Plain text file svm.php Aux. Auxiliary script
  Plain text file svn.php Aux. Auxiliary script
  Plain text file swish.php Aux. Auxiliary script
  Plain text file sync.php Aux. Auxiliary script
  Plain text file taint.php Aux. Auxiliary script
  Plain text file tcpwrap.php Aux. Auxiliary script
  Plain text file tokyo-tyrant.php Aux. Auxiliary script
  Plain text file trader.php Aux. Auxiliary script
  Plain text file uopz.php Aux. Auxiliary script
  Plain text file v8js.php Aux. Auxiliary script
  Plain text file varnish.php Aux. Auxiliary script
  Plain text file vpopmail.php Aux. Auxiliary script
  Plain text file weakref.php Aux. Auxiliary script
  Plain text file win32ps.php Aux. Auxiliary script
  Plain text file win32service.php Aux. Auxiliary script
  Plain text file wincache.php Aux. Auxiliary script
  Plain text file xattr.php Aux. Auxiliary script
  Plain text file xdiff.php Aux. Auxiliary script
  Plain text file xhprof.php Aux. Auxiliary script
  Plain text file xmldiff.php Aux. Auxiliary script
  Plain text file xmlreader.php Aux. Auxiliary script
  Plain text file xmlwriter.php Aux. Auxiliary script
  Plain text file yaf.php Aux. Auxiliary script
  Plain text file yaml.php Aux. Auxiliary script
  Plain text file yar.php Aux. Auxiliary script
  Plain text file yaz.php Aux. Auxiliary script
  Plain text file zip.php Aux. Auxiliary script
  Plain text file zmq.php Aux. Auxiliary script

  Files folder image Files  /  src  
File Role Description
  Plain text file PhpCodeAnalyzer.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:304
This week:4
All time:7,347
This week:42Up
 User Ratings  
 
 All time
Utility:91%StarStarStarStarStar
Consistency:91%StarStarStarStarStar
Documentation:91%StarStarStarStarStar
Examples:91%StarStarStarStarStar
Tests:-
Videos:-
Overall:73%StarStarStarStar
Rank:215