PHP_PHP で書かれた SVN クラスのチュートリアル
/**
* SVN 外部命令 类
*
* @author rubekid
*
* @todo comment need addslashes for svn commit
*
*/
class SvnUtils {
/**
*
* svn 账号
*/
const SVN_USERNAME = "robot";
/**
* svn 密码
*/
const SVN_PASSWORD = "robot2013";
/**
* 配置文件目录 (任意指定一个临时目录,解决svn: warning: Can't open file '/root/.subversion/servers': Permission denied)
*/
const SVN_CONFIG_DIR = "/var/tmp/";
/**
* svn list
*
* @param $repository string
* @return boolean
*
*/
public static function ls($repository) {
$command = "sudo svn ls " . $repository;
$output = self::runCmd ( $command );
$output = implode ( "
", $output );
if (strpos ( $output, 'そのリビジョンには存在しない' )) {
return false;
}
return "
" 。 $コマンド 。 "
" 。 $output;
}
/**
* svn copy
*
* @param $src string
* @param $dst string
* @param $comment string
* @return boolean
*
*/
public static function copy($src, $dst, $comment) {
$command = "sudo svn cp $src $dst -m '$comment'";
$output = self::runCmd ( $command );
$output = implode ( "
", $output );
if (strpos ( $output, 'コミットされたリビジョン' )) {
return true ;
}
「
」を返す。 $コマンド 。 "
" 。 $output;
}
/**
* svn delete
*
* @param $url string
* @param $comment string
* @return boolean
*
*/
public static function delete($url, $comment) {
$command = "sudo svn del $url -m '$comment'";
$output = self ::runCmd ( $command );
$output = implode ( '
', $output );
if (strpos ( $output, 'コミットされたリビジョン' )) {
return true;
}
戻る"
" 。 $コマンド 。 "
" 。 $output;
}
/**
* svn move
*
* @param $src string
* @param $dst string
* @param $comment string
* @return boolean
*/
public static function move($src, $dst, $comment) {
$command = "sudo svn mv $src $dst -m '$comment'";
$output = self::runCmd ( $command );
$output = implode ( '
', $output );
if (strpos ( $output, 'コミットされたリビジョン' )) {
return true ;
}
「
」を返す。 $コマンド 。 「
」 。 $output;
}
/**
* svn mkdir
*
* @param $url string
* @param $comment string
* @return boolean
*/
public static function mkdir($url, $comment) {
$command = "sudo svn mkdir $url -m '$comment'";
$output = self ::runCmd ( $command );
$output = implode ( '
', $output );
if (strpos ( $output, 'コミットされたリビジョン' )) {
return true;
}
"
" を返す。 $コマンド 。 「
」 。 $output;
}
/**
* svn diff
* @param $pathA string
* @param $pathB string
* @return string
*/
public static function diff($pathA, $pathB) {
$output = self::runCmd ( "sudo svn diff $pathA $pathB" );
return implode ( '
', $output );
}
/**
* svn checkout
* @param $url string
* @param $dir string
* @return boolean
*/
public static function checkout($url, $dir) {
$command = "cd $dir && sudo svn co $url";
$output = self::runCmd ( $command );
$output = implode ( '
', $output );
if (strstr ( $output, 'チェックアウトされたリビジョン' ) ) {
return true;
}
return "
" 。 $コマンド 。 「
」 。 $output;
}
/**
* svn update
* @param $path string
*/
public static function update($path) {
$command = "cd $path && sudo svn up";
$output = self::runCmd ( $command ) ;
$output = implode ( '
', $output );
preg_match_all ( "/[0-9]+/", $output, $ret );
if (! $ret [0] [0]) {
「
」を返す。 $コマンド 。 「
」 。 $output;
}
return $ret [0] [0];
}
/**
* svn merge
*
* @param $revision string
* @param $url string
* @param $dir string
*
* @return boolean
*/
public static function merge($revision, $url, $dir) {
$command = "cd $ dir && sudo svn merge -r1:$revision $url";
$output = implode ( '
', self::runCmd ( $command ) );
if (strstr ( $output, 'テキストの競合' )) {
return 'コマンド: ' 。 $コマンド 。 '
' 。 $output;
}
return true;
}
/**
* svn commit
*
* @param $dir string
* @param $comment string
*
* @return boolean
*/
public static function commit($dir, $comment) {
$command = "cd $dir && sudo svn commit -m'$comment '";
$output = implode ( '
', self::runCmd ( $command ) );
if (strpos ( $output, 'コミットされたリビジョン' ) || empty ( $output )) {
return true;
}
return $output;
}
/**
* svn status (WC内のファイルやディレクトリの状態を出力)
*/
public static function getStatus($dir) {
$command = "cd $dir && sudo svn st";
自分自身を返す: :runCmd ( $command );
}
/**
* SVN の競合
*
* @param $dir string
*/
public static function hasConflict($dir) {
$output = self::getStatus ( $dir );
foreach ( $output as $line ) {
if ( substr (rim( $ line ), 0, 1 ) == 'C' || (substr (rim ( $line ), 0, 1 ) == '!')) {
return true;
}
}
return false;
}
/**
* svn log
*
* @param $path string
* @return string
*
*/
public static function getLog($path) {
$command = "sudo svn log $path --xml";
$output = self::runCmd ( $command );
return implode ( '', $output );
}
/**
* svn info
* @param $path string
*/
public static function getPathRevision($path) {
$command = "sudo svn info $path --xml";
$output = self:: runCmd ( $command );
$string = implode ( '', $output );
$xml = new SimpleXMLElement ( $string );
foreach ( $xml->entry [0]->attributes () as $ key => $value ) {
if ( $key == 'リビジョン' ) {
return $value;
}
}
}
/**
* 最新のバージョン番号を取得します
* @param $path string
*/
public static function getHeadRevision($path) {
$command = "cd $path && sudo svn up";
$output = self::runCmd ( $command );
$output = implode ( '
', $output );
preg_match_all ( " /[0-9]+/", $output, $ret );
if (! $ret [0] [0]) {
return "
" 。 $コマンド 。 「
」 。 $output;
}
return $ret [0] [0];
}
/**
* ファイルの最も古いバージョン番号を取得します
*
* @param $filePath string
*
**/
public static function getFileFirstVersion($filePath){
$command = "sudo svn log {$filePath}" ;
$output = self::runCmd ( $command , "|grep -i ^r[0-9]* |awk '{print $1}'");
if(empty($output)){
return false ;
}
return str_replace("r", '', $output[count($output)-1]);
}
/**
* 2つのバージョンの間に変更されたファイル情報のリストを取得します *
*/
public static function getChangedFiles($path, $fromVersion, $headRevision ){
$files = array();
$pipe = "|grep -i ^Index:|awk -F : '{print $2}'";
$command = "svn diff -r {$fromVersion}:{$headRevision} $path";
$output = self::runCmd ( $command ,$pipe);
$files = array_merge($files, $output);
$command = "svn diff -r {$headRevision}:{$fromVersion} $path"; //文件删除可用逆对比
$output = self::runCmd ( $command ,$pipe);
$files = array_merge($files, $output);
return array_unique($files);
}
/**
* 2 つのバージョン間で変更されたファイルの内容を取得します
*
* @param $filePath string
* @param $fromVersion int
」*/
public static function getChangedInfo( $filePath, $fromVersion, $headRevision ){
$command = "sudo svn diff -r {$fromVersion}:{$headRevision} $filePath";
$output = self::runCmd ( $command );
return $output;
}
/**
*ファイルコンテンツの表示*/
public static function getFileContent($filePath, $version){
$command = "sudo svn cat -r {$version} $filePath";
$output = self::runCmd ( $command );
return $output;
}
/**
* cmdを実行してreturnresults
* @param $ commandstring
* @param $ pipe string(パイプラインを追加することができます。*/
保護された静的関数 runCmd($command , $pipe ="") {
$authCommand = ' --username ' . self::SVN_USERNAME 。 self::SVN_PASSWORD 。 「 --no-auth-cache --non-interactive --config-dir 」。 self::SVN_CONFIG_DIR 。 '.subversion';
exec ( $command . $authCommand . " 2>&1" . $pipe, $output );
return $output;
}
}
http://www.bkjia.com/PHPjc/328034.html
www.bkjia.com
true

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

メモ帳++7.3.1
使いやすく無料のコードエディター

SublimeText3 中国語版
中国語版、とても使いやすい

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

ホットトピック











PHP 8.4 では、いくつかの新機能、セキュリティの改善、パフォーマンスの改善が行われ、かなりの量の機能の非推奨と削除が行われています。 このガイドでは、Ubuntu、Debian、またはその派生版に PHP 8.4 をインストールする方法、または PHP 8.4 にアップグレードする方法について説明します。

あなたが経験豊富な PHP 開発者であれば、すでにそこにいて、すでにそれを行っていると感じているかもしれません。あなたは、運用を達成するために、かなりの数のアプリケーションを開発し、数百万行のコードをデバッグし、大量のスクリプトを微調整してきました。

Visual Studio Code (VS Code とも呼ばれる) は、すべての主要なオペレーティング システムで利用できる無料のソース コード エディター (統合開発環境 (IDE)) です。 多くのプログラミング言語の拡張機能の大規模なコレクションを備えた VS Code は、

JWTは、JSONに基づくオープン標準であり、主にアイデンティティ認証と情報交換のために、当事者間で情報を安全に送信するために使用されます。 1。JWTは、ヘッダー、ペイロード、署名の3つの部分で構成されています。 2。JWTの実用的な原則には、JWTの生成、JWTの検証、ペイロードの解析という3つのステップが含まれます。 3. PHPでの認証にJWTを使用する場合、JWTを生成および検証でき、ユーザーの役割と許可情報を高度な使用に含めることができます。 4.一般的なエラーには、署名検証障害、トークンの有効期限、およびペイロードが大きくなります。デバッグスキルには、デバッグツールの使用とロギングが含まれます。 5.パフォーマンスの最適化とベストプラクティスには、適切な署名アルゴリズムの使用、有効期間を合理的に設定することが含まれます。

文字列は、文字、数字、シンボルを含む一連の文字です。このチュートリアルでは、さまざまな方法を使用してPHPの特定の文字列内の母音の数を計算する方法を学びます。英語の母音は、a、e、i、o、u、そしてそれらは大文字または小文字である可能性があります。 母音とは何ですか? 母音は、特定の発音を表すアルファベットのある文字です。大文字と小文字など、英語には5つの母音があります。 a、e、i、o、u 例1 入力:string = "tutorialspoint" 出力:6 説明する 文字列「TutorialSpoint」の母音は、u、o、i、a、o、iです。合計で6元があります

このチュートリアルでは、PHPを使用してXMLドキュメントを効率的に処理する方法を示しています。 XML(拡張可能なマークアップ言語)は、人間の読みやすさとマシン解析の両方に合わせて設計された多用途のテキストベースのマークアップ言語です。一般的にデータストレージに使用されます

静的結合(静的::) PHPで後期静的結合(LSB)を実装し、クラスを定義するのではなく、静的コンテキストで呼び出しクラスを参照できるようにします。 1)解析プロセスは実行時に実行されます。2)継承関係のコールクラスを検索します。3)パフォーマンスオーバーヘッドをもたらす可能性があります。

PHPの魔法の方法は何ですか? PHPの魔法の方法には次のものが含まれます。1。\ _ \ _コンストラクト、オブジェクトの初期化に使用されます。 2。\ _ \ _リソースのクリーンアップに使用される破壊。 3。\ _ \ _呼び出し、存在しないメソッド呼び出しを処理します。 4。\ _ \ _ get、dynamic属性アクセスを実装します。 5。\ _ \ _セット、動的属性設定を実装します。これらの方法は、特定の状況で自動的に呼び出され、コードの柔軟性と効率を向上させます。
