php操作SVN版本服务器类代码_php技巧
SvnPeer.php
/**
*
* This class for execute the external program of svn
*
* @auth Seven Yang
*
*/
class SvnPeer
{
/**
* List directory entries in the repository
*
* @param string a specific project repository path
* @return bool true, if validated successfully, otherwise false
*/
static public function ls($repository)
{
$command = "svn ls " . $repository;
$output = SvnPeer::runCmd($command);
$output = implode("
", $output);
if (strpos($output, 'non-existent in that revision')) {
return false;
}
return "
" . $command . "
" . $output;
}
/**
* Duplicate something in working copy or repository, remembering history
*
* @param $src
* @param $dst
* @param $comment string specify log message
* @return bool true, if copy successfully, otherwise return the error message
*
* @todo comment need addslashes for svn commit
*/
static public function copy($src, $dst, $comment)
{
$command = "svn cp $src $dst -m '$comment'";
$output = SvnPeer::runCmd($command);
$output = implode("
", $output);
if (strpos($output, 'Committed revision')) {
return true;
}
return "
" . $command . "
" . $output;
}
/**
* Remove files and directories from version control
*
* @param $url
* @return bool true, if delete successfully, otherwise return the error message
*
* @todo comment need addslashes for svn commit
*/
static public function delete($url, $comment)
{
$command = "svn del $url -m '$comment'";
$output = SvnPeer::runCmd($command);
$output = implode('
', $output);
if (strpos($output, 'Committed revision')) {
return true;
}
return "
" . $command . "
" . $output;
}
/**
* Move and/or rename something in working copy or repository
*
* @param $src string trunk path
* @param $dst string new branch path
* @param $comment string specify log message
* @return bool true, if move successfully, otherwise return the error message
*
* @todo comment need addslashes for svn commit
*/
static public function move($src, $dst, $comment)
{
$command = "svn mv $src $dst -m '$comment'";
$output = SvnPeer::runCmd($command);
$output = implode('
', $output);
if (strpos($output, 'Committed revision')) {
return true;
}
return "
" . $command . "
" . $output;
}
/**
* Create a new directory under version control
*
* @param $url string
* @param $comment string the svn message
* @return bool true, if create successfully, otherwise return the error message
*
* @todo comment need addslashes for svn commit
*/
static public function mkdir($url, $comment)
{
$command = "svn mkdir $url -m '$comment'";
$output = SvnPeer::runCmd($command);
$output = implode('
', $output);
if (strpos($output, 'Committed revision')) {
return true;
}
return "
" . $command . "
" . $output;
}
static public function diff($pathA, $pathB)
{
$output = SvnPeer::runCmd("svn diff $pathA $pathB");
return implode('
', $output);
}
static public function checkout($url, $dir)
{
$command = "cd $dir && svn co $url";
$output = SvnPeer::runCmd($command);
$output = implode('
', $output);
if (strstr($output, 'Checked out revision')) {
return true;
}
return "
" . $command . "
" . $output;
}
static public function update($path)
{
$command = "cd $path && svn up";
$output = SvnPeer::runCmd($command);
$output = implode('
', $output);
preg_match_all("/[0-9]+/", $output, $ret);
if (!$ret[0][0]){
return "
" . $command . "
" . $output;
}
return $ret[0][0];
}
static public function merge($revision, $url, $dir)
{
$command = "cd $dir && svn merge -r1:$revision $url";
$output = implode('
', SvnPeer::runCmd($command));
if (strstr($output, 'Text conflicts')) {
return 'Command: ' . $command .'
'. $output;
}
return true;
}
static public function commit($dir, $comment)
{
$command = "cd $dir && svn commit -m'$comment'";
$output = implode('
', SvnPeer::runCmd($command));
if (strpos($output, 'Committed revision') || empty($output)) {
return true;
}
return $output;
}
static public function getStatus($dir)
{
$command = "cd $dir && svn st";
return SvnPeer::runCmd($command);
}
static public function hasConflict($dir)
{
$output = SvnPeer::getStatus($dir);
foreach ($output as $line){
if ('C' == substr(trim($line), 0, 1) || ('!' == substr(trim($line), 0, 1))){
return true;
}
}
return false;
}
/**
* Show the log messages for a set of path with XML
*
* @param path string
* @return log message string
*/
static public function getLog($path)
{
$command = "svn log $path --xml";
$output = SvnPeer::runCmd($command);
return implode('', $output);
}
static public function getPathRevision($path)
{
$command = "svn info $path --xml";
$output = SvnPeer::runCmd($command);
$string = implode('', $output);
$xml = new SimpleXMLElement($string);
foreach ($xml->entry[0]->attributes() as $key=>$value){
if ('revision' == $key) {
return $value;
}
}
}
static public function getHeadRevision($path)
{
$command = "cd $path && svn up";
$output = SvnPeer::runCmd($command);
$output = implode('
', $output);
preg_match_all("/[0-9]+/", $output, $ret);
if (!$ret[0][0]){
return "
" . $command . "
" . $output;
}
return $ret[0][0];
}
/**
* Run a cmd and return result
*
* @param string command line
* @param boolen true need add the svn authentication
* @return array the contents of the output that svn execute
*/
static protected function runCmd($command)
{
$authCommand = ' --username ' . SVN_USERNAME . ' --password ' . SVN_PASSWORD . ' --no-auth-cache --non-interactive --config-dir '.SVN_CONFIG_DIR.'.subversion';
exec($command . $authCommand . " 2>&1", $output);
return $output;
}
}

핫 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
시각적 웹 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

버전 관리는 PHP 개발에서 매우 일반적인 작업이며 가장 일반적으로 사용되는 도구는 SVN(Subversion)입니다. 공동 개발 중에 코드의 기록 버전과 코드 업데이트를 쉽게 관리할 수 있습니다. 다음은 PHP 개발에서 버전 관리를 위해 SVN을 사용하는 방법을 소개합니다. 1. SVN 클라이언트 및 서버 설치 먼저 SVN 클라이언트 및 서버를 설치해야 합니다. SVN 클라이언트는 SVN 공식 웹사이트에서 해당 버전을 다운로드하여 설치할 수 있으며, 서버는 직접 구축해야 합니다. 구체적인 방법은 다음과 같습니다.

SVN 소개 SVN(Subversion)은 코드 베이스를 관리하고 유지하는 데 사용되는 중앙 집중식 버전 제어 시스템입니다. 이를 통해 여러 개발자가 동시에 코드 개발에 협력할 수 있으며 코드 수정 내역에 대한 완전한 기록을 제공합니다. SVN을 사용하여 개발자는 다음을 수행할 수 있습니다. 코드 안정성을 보장하고 코드 손실 및 손상을 방지합니다. 코드 수정 내역을 추적하고 이전 버전으로 쉽게 롤백할 수 있습니다. 공동 개발, 여러 개발자가 충돌 없이 동시에 코드를 수정합니다. 기본 SVN 작업 SVN을 사용하려면 TortoiseSVN 또는 SublimeMerge와 같은 SVN 클라이언트를 설치해야 합니다. 그런 다음 다음 단계에 따라 기본 작업을 수행할 수 있습니다. 1. 코드 베이스 svnmkdirHttp://exampl을 생성합니다.

EclipseSVN 플러그인 설치 및 설정 방법에 대한 자세한 설명 Eclipse는 기능을 확장하기 위해 다양한 플러그인을 지원하는 널리 사용되는 통합 개발 환경(IDE)입니다. 그 중 하나는 개발자가 Subversion 버전 제어 시스템과 상호 작용할 수 있게 해주는 EclipseSVN 플러그인입니다. 이 기사에서는 EclipseSVN 플러그인을 설치 및 설정하는 방법을 자세히 설명하고 특정 코드 예제를 제공합니다. 1단계: EclipseSVN 플러그인 설치 및 Eclipse 열기

차이점: 1. vss는 Microsoft에서 개발했으며 유료인 반면 svn은 오픈 소스이며 무료입니다. 2. vss에는 클라이언트가 있어야 하지만 svn은 클라이언트, 명령줄 모드 또는 웹 페이지 액세스에서 읽기 전용을 사용할 수 있습니다. 3. vss는 Windows 시스템만 지원하는 반면, svn은 Windows 및 Linux 시스템을 지원합니다. 4. vss는 "잠금-편집-잠금 해제" 모드이고 svn은 기본적으로 "수정-충돌-병합" 모드입니다. vss는 단일 파일에 해당하며, svn의 버전 번호는 전체 버전 라이브러리에 해당합니다.

Linux에서는 svndiff 명령을 직접 사용하여 코드 수정 사항을 보는 것이 매우 어려우므로 인터넷에서 더 나은 솔루션을 검색했습니다. 특히 vimdiff 사용에 익숙한 사람들을 위해 svndiff의 코드 보기 도구로 vimdiff를 사용하는 것입니다. vim. 매우 편리합니다. svndiff 명령을 사용하여 특정 파일의 수정 사항을 비교할 때, 예를 들어 $svndiff-r4420ngx_http_limit_req_module.c 명령을 실행하면 다음 명령이 실제로 기본 diff 프로그램으로 전송됩니다. -u-Lngx_http_limit_req_module.c (개정4420)-Lngx_

CentOS에 SVN을 설치하는 것은 매우 일반적인 작업입니다. 소프트웨어 개발 중에 변경 사항을 관리하고 추적하는 데 사용할 수 있는 강력한 버전 제어 시스템입니다. 이 기사에서는 CentOS에 SVN을 설치하는 방법을 자세히 소개하고 일반적으로 사용되는 몇 가지 도구를 제공합니다. 라인 설치 방법. CentOS에 SVN을 설치하는 방법에는 여러 가지가 있습니다. 아래에서는 두 가지 일반적인 설치 방법을 소개합니다. 1. 터미널을 열고 루트 사용자로 로그인합니다. 2. 다음 명령을 실행하여 시스템 패키지 목록을 업데이트합니다. ``yumupdate3. 다음 명령을 실행하여 SVN을 설치합니다: yuminstallsubversion4. 설치가 완료된 후 다음 명령을 실행하여 SVN이 성공적으로 설치되었는지 확인할 수 있습니다. -V

Linux 개발자는 프로젝트 버전을 제어하기 위해 SVN을 사용해야 하는 경우가 많습니다. 우수한 개발자에게 SVN 버전을 확인하는 방법을 아는 것은 의심할 여지 없이 필수적인 기술 중 하나입니다. 오늘 저는 여러분이 이 실용적인 기술을 더 잘 익히는 데 도움이 되기를 바라며 이 기회를 빌어 여러분과 제 경험을 공유하고 싶습니다. 1. SVN 명령줄 도구를 설치하려면 먼저 Linux 환경에 SVN 명령줄 도구를 설치하세요! 터미널에 전화를 걸고 다음 명령을 안전하게 입력하여 설치를 완료하십시오. ```사용자님, Subversion을 설치하려면 sudoapt-getinstallsubversion을 실행하십시오. 2. SVN 서버에 연결 설치가 완료되면 SVN 서버에 연결해야 합니다. 다음 명령을 입력하십시오.

일반적으로 사용되는 서버 측 스크립팅 언어인 PHP는 오픈 소스 및 크로스 플랫폼 장점으로 인해 웹 개발 분야에서 널리 사용됩니다. 여러 사람이 함께 협업하는 개발에서 버전 관리는 소스 코드의 수정 및 업데이트를 효과적으로 관리하고 팀 구성원 간의 코드 동기화 중단으로 인한 충돌을 방지할 수 있는 필수 도구입니다. 널리 사용되는 버전 제어 도구인 SVN은 PHP 개발에도 널리 사용됩니다. 이 기사에서는 SVN 설치를 포함하여 PHP 개발에서 SVN 버전 제어에 대한 기본 지식을 소개합니다.
