Coder Social home page Coder Social logo

tomk79 / php-diffdir Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 2.52 MB

2つのディレクトリを比較し、検出された差分をレポートしてくれるコマンドです。ライブラリとしても利用できます。

PHP 3.09% CSS 0.67% HTML 94.88% C++ 0.01% JavaScript 1.35%

php-diffdir's Introduction

diffdir

diffdir は、2つのディレクトリを比較し、差分のあったファイルを抽出します。

比較した内容は1ファイル1行のCSVファイルに記録され、ファイルごとの差分を確認できるHTMLファイルを出力します。

インストール手順 - Install

diffdir のインストールには composer を使用します。

$ cd {$yourDirectory}
$ composer create-project tomk79/diffdir ./

使い方 - Usage

基本的な使い方 - Basic usage.

$ php ./diffdir.php {$path_dirA} {$path_dirB}

サンプルデータを比較する例 - Example: diff of sample data.

$ php ./diffdir.php ./tests/sample_a/ ./tests/sample_b/

オプション

-o 結果の出力先ディレクトリを指定する

-o オプションをつけて、出力先ディレクトリを指定します。

$ php ./diffdir.php -o ./result_sample/ ./tests/sample_a/ ./tests/sample_b/

--strip-crlf 改行コードを無視する

--strip-crlf オプションをつけて比較すると、改行コードだけの違いは無視されます。

$ php ./diffdir.php --strip-crlf ./tests/sample_a/ ./tests/sample_b/

-v 詳細なメッセージを出力する

-v オプションをつけて比較すると、ターミナル上に処理の詳細が表示されます。

$ php ./diffdir.php -v ./tests/sample_a/ ./tests/sample_b/

-q メッセージを表示しない

-q オプションをつけて比較すると、ターミナル上の表示の一切が隠されます。

$ php ./diffdir.php -q ./tests/sample_a/ ./tests/sample_b/

PHPスクリプト内で使用する

<?php
require_once( './vendor/autoload.php' );
$diffdir = new tomk79\diffdir(
	'/path/before/', // path before
	'/path/after/',  // path after
	array( // options
		'output'=>'/path/path_output_dir/', // -o
		'strip_crlf'=>true, // --strip-crlf
		'verbose'=>true // -v
	)
);
if( $diffdir->is_error() ){
	print 'ERROR.'."\n";
	var_dump( $diffdir->get_errors() );
}else{
	print 'success.'."\n";
	print ''."\n";
	print 'see: '.$diffdir->get_output_dir()."\n";
}

ライセンス - License

MIT License

作者 - Author

付録 - Appendix

composer のインストール

composer のインストール方法について 詳しくは composerの公式サイト(英語) を参照してください。

下記は公式サイトからの抜粋です。参考までに。

Macの方

Mac の方は、次のコマンドでグローバルインストールできます。

$ curl -sS https://getcomposer.org/installer | php
$ mv composer.phar /usr/local/bin/composer

Windowsの方

Windows の方は、GUIインストーラ Composer-Setup.exe が用意されています。 次のコマンドでもインストールできますので、お好みの方法でインストールしてください。

$ cd C:\bin
$ php -r "readfile('https://getcomposer.org/installer');" | php

開発者向け情報 - for Developer

テスト - Test

$ cd (project directory)
$ ./vendor/phpunit/phpunit/phpunit php/tests/diffdirTest

php-diffdir's People

Contributors

tomk79 avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar

php-diffdir's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.