[설치/설정] php5.3 으로 업그레이드시 자동 호환성 체크기 > PHP

본문 바로가기
사이트 내 전체검색

PHP

[설치/설정] php5.3 으로 업그레이드시 자동 호환성 체크기

페이지 정보

profile_image
작성자 최고관리자
댓글 0건 조회 10,531회 작성일 21-02-09 11:49

본문

출처 : http://phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=72898

오늘 PHP 관련 뉴스레터에서 버전업된 호환성 체크기(php4, php5.1, php5.2 버전)가 포스팅되어 이를 소개합니다.

 [원문]
http://techblog.wimgodden.be/2010/06/24/automated-php-5-3-compatibility-testing-for-your-old-code/

 [참조]
http://www.php.net/manual/en/migration53.new-features.php : php5.3 버전에서 달라지는 것들
http://code.zikula.org/phpcs/wiki/installation : PHP_CodeSniffer 설치(pear)

이 호환성 체크기의 목적은 PHP_CodeSniffer를 기반으로 한 PHP5.3 으로 버전업시 발생되는 문제점을 리스트하는데 있습니다.

이런 것 안써도 그냥 php버전업 하시고 일일이 에러사항 확인하고 수정도 하지만, 좀 더 자동화하자는 것에 의의가 있겠습니다.

우선, 현재 테스트 환경은 PHP5.3 이 깔려 있어야 합니다. 저는 테스트 용도로 윈도우 기반에서 돌렸습니다.

 [설치순서]
1. pear 를 통한 PHP_CodeSniffer 1.3 이후 버전 설치 (http://pear.php.net/PHP_CodeSniffer)

 2. PHP5.3 호환성 체크용 룰셋 다운받기 (https://github.com/wimg/PHP53Compat_CodeSniffer/downloads)

우선, pear 리스트에 PHP_CodeSniffer가 설치되어 있는 지 확인하고 없거나, 버전이 1.2.2 stable로 되어 있는 경우, 이를 1.3.0RC1으로 재설치 합니다.

 > pear list                    => 목록확인

> pear install PHP_CodeSniffer-alpha        => 설치후 PHP_CodeSniffer 1.3.0RC1 beta 로 설치됩니다.

다음, pear 설치 디렉토리로 이동한 뒤에 호환성 체크 룰셋 적용한 파일들을 다운 받습니다.

 > cd C:\Server\PHP\PEAR                      : pear 디렉토리
> cd PHP\CodeSniffer\Standards              : CodeSniffer 디렉토리
> git clone git://github.com/wimg/PHP53Compat_CodeSniffer.git PHP53Compatibility

 git 가 설치되어 있지 않다면 https://github.com/wimg/PHP53Compat_CodeSniffer/downloads 이곳에서 파일 다운받으시고 Standards 디렉토리에

PHP53Compatibility디렉토리로 이름변경하고 추가하시면 될 것입니다.


설치된 PHP53Compatibility 디렉토리 안에는 아래의 파일과 디렉토리가 있게 됩니다.
    README.markdown
  ruleset.xml
    Sniffs 디렉토리

[실행]
 > phpcs --standard=PHP53Compatibility <테스트할 php source 디렉토리>

만약, 테스트할 php 코드가 .php뿐만 아니라 .html .inc 도 있을 경우 --extensions 옵션을 추가합니다.
 > phpcs --extensions=php,html,inc --standard=PHP53Compatibility <테스트할 php source 디렉토리>

 [실행결과]
FILE: C:\workspacePHP\test.php
 --------------------------------------------------------------------------------
 FOUND 0 ERROR(S) AFFECTING 1 LINE(S)
 --------------------------------------------------------------------------------
1 | WARNING | No PHP code was found in this file and short open tags are not
    |                | allowed by this install of PHP. This file may be using short
    |                | open tags but PHP does not allow them.
 --------------------------------------------------------------------------------



이렇게 나온 경우는 해당 php 파일에 short open tag(<?)를 사용했거나, php 코드가 없는 경우 입니다.

--------------------------------------------------------------------------------
2 | WARNING | The use of function ereg() is discouraged; use preg_match() instead
 4 | WARNING | The use of function split() is discouraged; use preg_split() instead



 9 | WARNING | The use of function ereg_replace() is discouraged; use preg_replace() instead



 --------------------------------------------------------------------------------

이런 식으로 호환성 결과가 나옵니다.

파일이 많을 경우 지체되는 경우도 있어, 디렉토리별로 실행하시고 결과를 파일로 남겨서 살펴보시면 유용할 듯 싶습니다.


 [결론]
설치도 간단하고 한번 돌려볼 만 합니다.

CodeSniffer - (표준화 코딩방법을 위하여) 사용하면 아주 유용할 것 같습니다.




-----------------------------------------------------------------------------------------
업그레이드에 대한 추가 참고 사이트
http://php.net/manual/kr/faq.migration5.php

댓글목록

등록된 댓글이 없습니다.

회원로그인

회원가입

  • 게시물이 없습니다.

접속자집계

오늘
1,781
어제
4,039
최대
6,642
전체
830,296
contact : webmaster@beautipia.co.kr
Copyright © beautipia.co.kr. All rights reserved.