PHP7 introduced the syntax tree, so the static syntax analysis is more convenient.
1, first install PHP7, to http://windows.php.net/download php7 with OpenSSL.
2, modify the php.ini,
Extension=php_openssl.dll
Extension=php_sockets.dll
Extension=php_sqlite3.dll
Extension=php_pdo_sqlite.dll
The preceding semicolon is removed, this step is to install the composer.
3, install composer, I failed to install, direct download Composer.phar
Create a new batch Composer.bat
@echo off"%~dp0php.exe" "%~dp0composer.phar"%*
Modify composer Source to Chinese mirror,
composer config -g repo.packagist composer http://packagist.phpcomposer.com
4, install Php_ast module, Phan need, put the DLL into the EXT directory,
Extension Add a row
Extension=php_ast.dll
5, Installation Phan
Open the command line to switch to the PHP7 directory, run
Composer require--dev "Etsy/phan:dev-master"
The detailed use of Phan can be consulted
Https://github.com/etsy/phan
6. Analysis Project
Create a new batch, for example, first analyze the PHP code under F:\WORK\SRC, and then use SED to remove unused hints.
@echo off set src=f:\work\set phin=%src%\phan_in.txt set Phout=%src%\phan_out. txt find %src%-type f-name "*.php" >%phin%phan-f%phin%-o%phout%sed-i "/\phalcon/d" %phout%sed-i "/redis/ D "%phout%sed-i "/memcached/d "%phout%sed-i "/vendor/d" %phout% echo " The syntax check is complete, see%phout% "@ pause
Find and SED are not available under Windows, but there are native ports that do not require Cygwin and MinGW
Download Http://sourceforge.net/projects/unxutils/files/latest/download
and Http://unxutils.sourceforge.net/UnxUpdates.zip.
After decompression, cover the unxutils\usr\local\wbin with unxupdates and remove sed and find.
7, can be Phan new batch and Phan directory peer, Phan.bat
@echo off"%~dp0php.exe" "%~dp0phan\phan"%*
Put the Php.exe directory in the environment variable path so that you can configure some Ides to call Phan.bat to check the current code.
phan-php syntax static check configuration under Windows