태그 : php

php] manual 중 Userland Naming GuideUserland Naming Guide Table of Contents Global Namespace Rules

from. http://www.php.net/manual/kr/userlandnaming.php

사용자 네이밍 가이드

목차

  • 전역 이름 공간

  • 규칙



다음은 좋은 결과를 위해 사용자의 PHP 코드 내 식별자로서 이름을 선택하는 방법에 대한 가이드이다. 전역 공간에 심볼을 생성하게 될 코드 내에서 어떤 이름을 선택할 때, 다음의 가이드라인을 고려하는 것은 미래의 PHP 코드에서 당신의 심볼과의 충돌을 방지하는데 중요한 역할을 할 것이다.

전역 이름 공간

전역 이름 공간에서 다룰 코드 구조의 개요는 다음과 같다.

  1. functions 함수

  2. classes 클래스

  3. interfaces 인터페이스

  4. constants ( not class constants ) 상수 (클래스 상수는 아님)

  5. variables defined outside of functions/methods (함수나 메소드 밖에서 정의된 변수)


규칙

다음은 PHP 프로젝트 자체적으로 새로운 지시자의 명명에 대한 개요이다. 공식적인 가이드는 CODING STANDARDS 를 참고할 것.

  • PHP 는 최고 레벨의 이름공간을 소유하지만, 명백한 충돌을 피하면서 괜찮은 표현의 이름을 찾으려고 시도한다.

  • 함수명은 단어 사이에 밑줄을 사용하고, 클래스명은 낙타 명명법을 사용한다(구버젼의 경우 예외가 존재함).

  • 확장(패키지)의 이름을, 확장에 대한 전역 이름의 prefix;접두어 로 사용한다. (과거에는 꽤 많은 예외가 있었음)
    예를 들면,

    curl_close()
    mysql_query()
    PREG_SPLIT_DELIM_CAPTURE
    new DOMDocument()
    strpos() (과거의 예외임)
    new SplFileObject()

  • iterator 와 exception 은 단순하게 접미어로 사용한다.
    ArrayIterator
    LogicException

  • PHP 는 __ (밑줄 2개)로 시작하는 모든 심볼을 magical 로 사용한다. 그러므로, 사용자는 기문서화된 magical 기능을 사용할 것이 아니라면, 사용자 심볼로 __ 로 시작하는 심볼을 사용하지 말 것을 권고한다.
    예를 들면,

    __get()
    __autoload()




미래를 대비한 코드를 작성하고자 한다면, 일상적이지 않은 3~4 문자의 접두어나 접미어를 사용할 것을 권고한다. 또한, 다른 사용자 코드와의 충돌을 대비하려면, 사용하려는 접두어/접미어가 여타 프로젝트에서 사용 중인지 확인한 후, 적절한 방법으로 사용중임을 알리기를 권한다.

예를들면,

  • MyPx_someFunc()

  • Foo_Date

  • $asdf_dbh


.

by 낭망백수 | 2009/02/06 16:11 | linguistics | 트랙백 | 덧글(0)

memo/php] from zend coding convention

from Zend PHP Framework Manual

Appendix B. Zend Framework Coding Standard for PHP

Scope
  • PHP File Formatting
  • Naming Conventions
  • Coding Style
  • Inline Documentation
end.

by 낭망백수 | 2009/02/03 02:17 | fr_code | 트랙백 | 덧글(0)

memo/php] zend framework screencast summary

http://framework.zend.com/docs/screencasts

1. installing
  • zend framework 압축파일 중에서 library 만 있으면 된다.
  • rewriterule 과 pretty url
  • front controller 는 PUBLIC_HOME 폴더에,
  • application 서비스 로직은 application 폴더에.
2. bootstrapping
  • Error_Reporting
  • include_path
  • loading Zend_Loader
  • setup Front Controller Zend_Controller_Front
  • uri : http://domain.com/applicationRoot/controllerName/actionName
3. controllers & views
  • writting my own first controller
  • ㄴclass IndexController extends Zend_Controller_Action
  • ㄴpublic function indexAction
  • with view
  • ㄴHOME_PATH/application/views/scripts/index/index.phtml
  • writting my own Error Controller
  • ㄴclass ErrorController extends Zend_Controller_Action
  • ㄴㄴpublic function errorAction
  • ㄴHOME_PATH/application/views/scripts/error/error.phtml
4. extending
  • Example about Runtime Environment Configuration
  • importing Zend_Config_Ini
  • ㄴZend_Loader::loadClass('Zend_Config_Ini');
  • ㄴ$config = new Zend_Config_Ini('../application/config.ini', 'testGroup');
end.

by 낭망백수 | 2009/01/31 18:34 | fr_code | 트랙백 | 덧글(4)

◀ 이전 페이지          다음 페이지 ▶