以下のURLからSonarQube と SonarQube Runner をダウンロードして解凍する。

http://www.sonarqube.org/downloads/

c:\ 直下に置く。


C:\sonarqube-4.5
C:\sonar-runner-2.4

以下のURLから無料Javaをダウンロードしてインストールする。

http://java.com/ja/download/

とりあえずポスグレでデータベースsonarを作っておく。


c:\Program Files\PostgreSQL\9.3\bin\createdb -U postgres sonar

C:\sonarqube-4.5\conf\sonar.properties の以下の部分をコメントアウトを外す、もしくは編集。


# User credentials.
# Permissions to create tables, indices and triggers must be granted to JDBC user.
# The schema must be created first.
sonar.jdbc.username=postgres
sonar.jdbc.password=password

#----- PostgreSQL 8.x/9.x
# If you don't use the schema named "public", please refer to http://jira.codehaus.org/browse/SONAR-5000
sonar.jdbc.url=jdbc:postgresql://localhost/sonar

C:\sonar-runner-2.4\conf\sonar-runner.propertiesの以下の部分を編集もしくはコメントアウトを外す。


#----- PostgreSQL
sonar.jdbc.url=jdbc:postgresql://localhost/sonar

#----- Global database settings
sonar.jdbc.username=postgres
sonar.jdbc.password=password

起動。


C:\sonarqube-4.5\bin\windows-x86-64\StartSonar.bat

http://localhost:9000

に接続。
admin:admin
でログインしてsettingsからupdate centerを選んでプラグインとかいろいろいれておく。

自分の作成した(調べたい)プロジェクトのディレクトリにcdして、以下のURLのサンプルを参考にsonar-project.propertiesファイルを設置する。

https://github.com/SonarSource/sonar-examples/blob/master/projects/languages/php/php-sonar-runner/sonar-project.properties

そのままプロジェクトのディレクトリ内で、以下を実行。


C:\sonar-runner-2.4\bin\sonar-runner.bat

ちなみにこの自分のプロジェクトディレクトリに置くsonar-project.propertiesファイルだけど、以下の一行


sonar.language=php

を消せば、他の言語(jsとかcssとかhtmlとか)もまとめてやってくれる。
jquery.min.jsとかbootstrap.cssとかを除外するには、以下のようなパラメータを追加する。(CakePHPの例)


sonar.exclusions=app/webroot/js/lib/*.js,app/webroot/css/bootstrap*css,app/webroot/css/cake.generic.css 

あるいは9000画面から設定→除外→Filesへ。