phan-php syntax static check configuration under Windows

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.