Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Bài 3 - PHP standards recommendations. Những nội dung chính được trình bày trong bài này gồm có: Basic coding standard, coding style guide, logger interface, autoloading standard, caching interface, HTTP message interface. . | Bài giảng Phát triển phần mềm nguồn mở: Bài 3 - Nguyễn Hữu Thể PHÁT TRIỂN PHẦN MỀM NGUỒN MỞ PHP Standards Recommendations Nguyễn Hữu Thể Content Basic Coding Standard Coding Style Guide Logger Interface Autoloading Standard Caching Interface HTTP Message Interface 2 Index by Status (Accepted) Num Title Editor Coordinator Sponsor 1 Basic Coding Standard Paul M. Jones N/A N/A 2 Coding Style Guide Paul M. Jones N/A N/A Jordi 3 Logger Interface N/A N/A Boggiano 4 Autoloading Standard Paul M. Jones Phil Sturgeon Larry Garfield Paul 6 Caching Interface Larry Garfield Robert Hafner Dragoonis Matthew HTTP Message Beau 7 Weier Paul M. Jones Interface Simensen O'Phinney Matthew Marc 13 Hypermedia Links Larry Garfield Weier Alexander O'Phinney http://www.php-fig.org/psr/ 3 PSR-1: Basic Coding Standard 1. Overview Files MUST use only PSR-1: Basic Coding Standard SHOULD NOT SHOULD PSR-1: Basic Coding Standard Namespace and Class Names Namespaces and classes MUST follow an "autoloading" PSR: [PSR-0, PSR-4]. Class names MUST be declared in StudlyCaps. // PHP 5.3 and later: namespace Vendor\Model; class Foo { } 6 PSR-1: Basic Coding Standard Class Constants, Properties, and Methods The term "class" refers to all classes, interfaces, and traits. Class constants MUST be declared in all upper case with underscore separators. namespace Vendor\Model; class Foo { const VERSION = '1.0'; const DATE_APPROVED = '2012-06-01'; } 7 PSR-1: Basic Coding Standard Properties • This guide intentionally avoids any recommendation regarding the use of $StudlyCaps, $camelCase, or $under_score property names. Methods • Method names MUST be declared in camelCase(). 8 PSR-2: Coding Style Guide Code MUST use 4 spaces for indenting, not tabs. There MUST NOT be a hard limit on line length; the soft limit MUST be 120 characters; lines SHOULD be 80