Home
pdf version - ShnfuCarver 1.0 documentation
Contents
1. return Sthis gt addError return true 1 1 PHP Coding Standards 7 ShnfuCarver Documentation Release 1 0 1 1 11 Function Calls Functions should be called without space between function s name and starting bracket There should be one space between every parameter of a function call Also one space on either side of the equal sign used to assign the return value to a variable Split long assignment with the equal sign indented on the following line lt php Svar foo Sbar Sbar2 Sbar3 SGLOBALS TSFE gt additionalHeaderData Sthis gt strApplicationName this gt xajax gt getJavascript t3lib extMgm siteRelPath nr xajax gt For a long or nested function calls and arrays lt php Sthis gt someObject gt subObject gt callThisFunctionWithALongName Sthis gt someOtherFunc Sthis gt someEvenOtherFunc Help me array Fos gt bar spam gt eggs 23 Sthis gt someStillOtherFunc Sthis gt wowowowowow 12 gt For a chaining call lt php Semail gt from foo example com gt to barfexample com gt subject A great message gt send 2 gt Avoid using recursive function because too many levels of recursion may cause stack overflow Using iteration instead where recursion needed 1 1 12 Naming Conventions This is a table for easy search 8 Chapter 1 Coding Standards
2. the name should comply with the following e Use only singular form in all the names e All names should be lowercase with separating words e A table should have a primary key named as id e A foreign key name should be the related table name followed by id TODO Write a simple example 1 2 2 URI Design All URI should be independent of programming language and file names That means the server could be totally rewritten by another programming language without changing any of the URIs Generate absolute URI in the pages not relative URL In this case a page saved to other place will looks exactly like the original one 1 2 ShnfuCarver Coding Standards 11 ShnfuCarver Documentation Release 1 0 12 Chapter 1 Coding Standards CHAPTER TWO DEVELOPMENT ENVIRONMENT AND TOOLS 2 1 Development Environment 2 1 1 Programming Language PHP 2 1 2 Database MySQL 2 1 3 Server Debian 2 1 4 HTTP Server Nginx and Apache HTTP Server with php module Install these packages via apt get Direct access via nginx for static objects image js favicon ico robots txt Rewrite all other URI request to index php Proxy php request to apache Settings for security Hide the version information Also remember to hide the PHP info in the header 2 2 Development Tools This chapter describes some utilities which could assist the development process Some of them could be picked as you like e g
3. Autoloader e Dispatcher Router Request Response e View Layout Helper e Model e Log 3 3 1 Config In ShnfuCarver most settings are configurable via Config module There will be global and local config An application have a global one while each manager could have their own File and module paths The only paths which should be set externally are the ShnfuCarver path and the config uration path itself e System settings Error level log level e Load and autoload e Data source The Config module does not directly interact with any other modules except Manager All settings are retrieved and set to other modules by Manager in order to reduce the coupling A default configuration is designed internally So the application could work well with the minimal settings An application could have many configurations which can be switched by the configuration name like development production etc One configuration could be originated from another one and then modified 3 3 Framework Components 17 ShnfuCarver Documentation Release 1 0 3 3 2 Debug Error Using observer pattern for error handler User can add its own handler A handler that implements HanderInterface could be appended to be an observer The Error module should deal with the PHP system and user errors The system error reporting level can be set by the application Errors can be displayed in the web page and or put into the log module
4. Documentation ShnfuCarver Documentation Release 1 0 Links to other pages doc Other pages in the documentation can be linked to using the doc role You can link to the specified doc ument using either an absolute or relative path reference You should omit the rst extension For exam ple if the reference doc form appears in the document core helpers html then the link refer ences core helpers form If the reference was doc core helpers it would always reference core helpers regardless of where it was used Cross referencing links ref You can cross reference any arbitrary title in any document using the ref role Link label targets must be unique across the entire documentation When creating labels for class methods it s best to use class method as the format for your link label The most common use of labels is above a title Example _label name Section heading More content here Elsewhere you could reference the above section using ref label name The link s text would be the title that the link preceded You can also provide custom link text using ref Link text lt label name gt 5 1 7 Describing classes and their contents The CakePHP documentation uses the phpdomain to provide custom directives for describing PHP objects and con structs Using these directives and roles is required to give proper indexing and cross referencing features 5 1 8 Describing class
5. Exception Like the Error module using oberver pattern to handle uncaught exception Implements HandlerInterface to cus tomize your own method 3 3 3 Loader The load of class could be set manually by configuration An automatic mechanism is provided if the class file path follows certain regulation A map is provided to connect between names and paths The path could be an array The Loader process is shown below while the direction of search could be reversed This process ends while a file is found and loaded 1 Search the class name in the file map 2 If not found extract the namespace from the class name Use empty string for no namespace If sub namespace exists choose the empty or longest one depend on the direction of search There will be one or several directories connected with the namespace Then search the file with the same name as the class 3 If not found try to extend or shorten the name of the sub namespace with one level Then do the same as above If still not found repeat this step This step is ended by null namespace Here is an example For the class ShnfuCarver Controller Error with reversed search direction 1 Search the file path ShnfuCarver Controller Error in the map If the file found just load it and end this search 2 Search ShnfuCarver Controller in the directory map If found search Error php under the direc tory or directories 3 Search ShnfuCarver in the dire
6. ShnfuCarver Documentation Release 1 0 Element Name Example Namespace FooBar BarFoo Interface FooBar Class FooBar Method Function fooBar Private Protected Method _fooBar Variable fooBar Constant FOO_BAR Array Key foo_bar Use meaningful English word s for names do NOT use Pinyin It would be great if others could understand what the code will do just by the names Do not use all uppercase abbreviations wat chNBAGame should be wat chNbaGame Some common prefix to indicate special meaning for methods e The prefix is should be used for methods returning a boolean value e The prefix set and get for setting and retrieving properties Do not set properties public Prefix for Type of Methods and Properties Private and protected class members are preceded by a single underscore _ Do NOT use double underscore __ because it is the prefix of magical constants of PHP Interface Name Class and interface name should be written in CamelCase lt php interface Template public function createProfile fileName Class Name Class name should be written in CamelCase lt php class Userkey FA ss Namespace Name Namespace should be written in CamelCase lt php namespace ShnfuCarver CoreControl gt 1 1 PHP Coding Standards ShnfuCarver Documentation Release 1 0 Method and Function Name Method name should be like an action and written in
7. editors while some are required e g Git 2 2 1 Editor The vim or emacs is recommended as the program editor 13 ShnfuCarver Documentation Release 1 0 Vim See the official site Type help in vim to see the vim user manual A Chinese version of vim user manual is also available Emacs See the Emacs 2 2 2 Revision Control Git The Git Reference is strongly recommended if you are new to Git And the more detailed book Pro Git is good for more comprehensive knowledge It also has a Simplified Chinese Version of Pro Git 14 Chapter 2 Development Environment and Tools CHAPTER THREE SHNFUCARVER DESIGN Note Need a proper name for this framework 3 1 Framework Architecture ShnfuCarver is designed to be the framework of Shnfu It should be powerful and efficient for the future Shnfu application design ShnfuCarver is subject to the new BSD license The license file license txt must be placed under the root directory of the distributed files 3 1 1 Model View Controller MVC Pattern ShnfuCarver uses the MVC pattern A detailed article about MVC could be found in Model View Controller MVC in PHP MVC is widely used among a great many PHP frameworks Like Symfony CakePHP Codelgniter Zend Framework etc Use of the MVC pattern results in separating the different aspects of the application business logic and UI logic input logic while providing a loose coupling between these element
8. not be included again by include_once 1 1 6 Comment A good program should be understood even without comments But proper comments could make the reading easier You do not need to write comments everywhere in the code if the code is in good style The comment should appear in the following situation 1 Some complicated algorithm 2 Where misunderstanding could happen 3 Some tricks that others may not notice 4 Any codes where others may not understand or even you may forget the meaning after a few days All comments should be written in English and should in a clear way describe the commented block of code 4 Chapter 1 Coding Standards ShnfuCarver Documentation Release 1 0 1 1 7 Indentation 4 spaces used for indentation Do NOT use tab Editors should be configured to treat tabs as spaces in order to prevent injection of tab characters into the source code Indentation using Allman style lt php SboolVariable true SstringVariable cat if SboolVariable echo Bool value is true if SstringVariable cat echo Such a lovely cat 1 1 8 Control Structures One space between the keyword and the opening parenthesis Always use curly braces in control structures even if they are technically optional Having them increases the read ability and introduces fewer logical errors when new lines added Start both the curly braces in a new line Allman style Avoid crea
9. text and could be confused with inline markup delimiters they have to be escaped with a backslash Inline markup has a few restrictions It may not be nested e Content may not start or end with whitespace x text is wrong e Content must be separated from surrounding text by non word characters Use a backslash escaped space to work around that onelong bolded word 5 1 5 Lists List markup is very similar to markdown Unordered lists are indicated by starting a line with a single asterisk and a space Numbered lists can be created with either numerals or for auto numbering This is a bullet So is this But this line has two lines f First line 2 Second line Automatic numbering Will save you some time Indented lists can also be created by indenting sections and separating them with an empty line First line Second line Going deeper x Whoah x Back to the first level Definition lists can be created by doing the following term definition CakePHP An MVC framework for PHP Terms cannot be more than one line but definitions can be multi line and all lines should be indented consistently 5 1 6 Links There are several kinds of links each with their own uses External links Links to external documents can be with the following External Link lt http example com gt _ The above would generate a link pointing to http example com 26 Chapter 5 About
10. Scondition3 Sfoo Shar Sc Scondition4 amp amp Scondition5 foo_man_this_is_too_long_what_should_i_do Sbar gt 6 Chapter 1 Coding Standards ShnfuCarver Documentation Release 1 0 Since PHP 5 3 it is possible to leave out the middle part of the ternary operator Expression exprl expr3 returns expr if expr evaluates to TRUE and expr3 otherwise So the following is an neat way to do this lt php Svaluel Svalue2 some string Sresult1 will be default Sresultl Svaluel default this is identical to the above Sresultl Svaluel Svaluel default Sresult2 will be some string Sresult2 Svalue2 default gt 1 1 9 Array Assignments in arrays may be aligned When splitting array definitions onto several lines the last value may also have a trailing comma This is a valid PHP syntax and helps to keep code diffs minimal lt php SsomeArray array too gt bar spam gt ham 2S 1 1 10 Function Definition Arguments with default values go at the end of the argument list Try to make functions return something at least true or false so it can be determined whether the function call is successful lt php function connection dns Spersistent false if is array Sdns SdnsInfo Sdns else SdnsInfo BD parseDNS dns if SdnsInfo SdnsInfo phpType
11. ShnfuCarver Documentation Release 1 0 Little Tiger March 15 2012 1 Coding Standards 1 1 PHP Coding Standards 1 2 ShnfuCarver Coding Standards 2 Development Environment and Tools 2 1 Development Environment 2 2 Development Tools 3 ShnfuCarver Design 3 1 Framework Architecture 3 2 Kernel Architecture 3 3 Framework Components 3 4 Application Hierarchy 4 Shnfu Design 5 About Documentation 5 1 Documentation formatting guide 6 Indices and Tables Index CONTENTS 13 pees ios dae es ine ce I ager chs toe O de Ge NM Sr ele 13 Leeann ME eae SOM QE ew a ek RES 2 Oe E 13 15 BAS DS Seo ak NS ITS ed Ge TRUST eS 15 Lake ER eee E 6 E A eee ee RME Mme Ae 16 Bee SMS ee JRR CDU ar q E e De SDS do 17 Da hee oR poda ada ee sn Lee tes ne nS Cope amp 4 20 23 25 ag do te ee d en de Fe ARR os Sha O E ES 25 31 33 ShnfuCarver Documentation Release 1 0 This is the design documentation of ShnfuCarver framework the guide for the whole framework development Developers should read this before coding There is also a pdf version This documentation could be revised if there is any good suggestion CONTENTS 1 ShnfuCarver Documentation Release 1 0 2 CONTENTS CHAPTER ONE CODING STANDARDS 1 1 PHP Coding Standards Developers should always keep in mind all items listed in this chapter These are the basic conventions for all the PHP coding 1 1 1 Qu
12. camelCase translate loadClass Property Variable and Parameter Name Written in camelCase house someProperty globalVar Do not use old fashion var to declare properties Try to initialize the properties in order to set a fixed type lt php class FooBar private SsimpleBoolean false private SsimpleInt 0 private SsimpleFloat 0 0 private SsimpleString private SsimpleArray array private SsimpleNull null Constant Name Constants should be all uppercase with underscores to separate words lt php class FooBar const A CONSTANT VARIABLE 1234 const ANOTHER CONSTANT STRING Haha gt Constants must be defined as class members with the const modifier Defining constants in the global scope with the define function Array Key Name gt 1 No for magic quote lt php SsomeArray array foo_bar gt Pretty good monday 2 gt 10 Chapter 1 Coding Standards ShnfuCarver Documentation Release 1 0 1 1 13 Coding Standard Tool PHP_CodeSniffer 1 1 14 Reference This chapter is inspired by the following e PEAR Coding Standards e Zend Framework Coding Standard for PHP e CakePHP Coding Standards e PHP Coding Standard 1 2 ShnfuCarver Coding Standards 1 2 1 Database Naming Conventions Since the framework may use a third party ORM library It may have its own naming conventions required by the library But in general
13. class role 28 php const directive 27 php const role 28 php exc role 29 php exception directive 27 php func role 28 php function directive 27 php global directive 27 php global role 28 php meth role 28 php method directive 28 php staticmethod directive 28 R ref role 27 INDEX 33
14. ctory map If found search Controller Error php under the direc tory or directories 4 Search an empty namespace in the directory map If found search ShnfuCarver Controller Error php under the directory or directories Autoloader The Autoloader will hold many Loader instances The loaders may also be considered as the oberver Multiple Autoloader instance is allowed since the spl autoload register function could be called repeatedly The framework could use the autoload mechanism in development for convenience But a presetted file map should be built in release version in order to save the cpu time Maybe a cache mechanism could help here 18 Chapter 3 ShnfuCarver Design ShnfuCarver Documentation Release 1 0 3 3 4 Dispatcher Request The Request includes all the information received from the browser They may have the Server Header Get Post File and Cookie modules Headers are achieved from the SERVER variable A lot of other useful information is also analyzed from the server variable Server Get Post and Cookie data have similar structrue They could be described together Response The Response is the content sent back to the browser They will have the Header Cookie and Body modules There may be many kinds of headers A HeaderCollection will manager all of them The status header may be handled separately Router The Route module processes the path info and translate it into a command Th
15. e command will be used to decide which controller to load Then the controller should send a response back A command has properties of controller action and parameters The process of a router is PathInfo gt Rewrit gt Parser gt Command There will be a standard parser to parse a URI like http example com controller action param param2 param3 option l value amp option2 value2 The rewrite rule will allow different URI form It will rewrite the path info first before it send to parser A default controller should be set if no controller specified If no action specified then the index action will be chosen If specified controller or action not found an error controller or action should handle this situation and send a 404 error status These default and error controller can certainly be customized by application Generator Generator is used to generate the URI according to the controller action and parameters which is opposite to the Router The process of a generator is Command gt Deparser gt Rewrit gt PathInfo 3 3 5 View The View module will load a template as the response body It is easy to implement a static template But no parameters could be sent to that There might be other choices that could be used as template Such as Smarty and Twig The View module is often loaded by a controller s action and send to the response as body 3 3 Framework Components 19 ShnfuCarver Documentatio
16. es and constructs Each directive populates the index and or the namespace index php global name This directive declares a new PHP global variable php function name signature Defines a new global function outside of a class php const name This directive declares a new PHP constant you can also use it nested inside a class directive to create class constants php exception name This directive declares a new Exception in the current namespace The signature can include constructor argu ments php class name Describes a class Methods attributes and constants belonging to the class should be inside this directive s body 5 1 Documentation formatting guide 27 ShnfuCarver Documentation Release 1 0 php class MyClass Class description php method method Sargument Method description Attributes methods and constants don t need to be nested They can also just follow the class declaration php class MyClass Text about the class php method methodName Text about the method See Also php method php attr php const php method name signature Describe a class method its arguments return value and exceptions php method instanceMethod Sone Stwo param string Sone The first parameter param string Stwo The second parameter returns An array of stuff throws InvalidArgumentException This is an instance method php staticmethod ClassName methodName signatu
17. ick Style Overview This is an example which includes some of the standards in this chapter It does not include everything but developers could have a straightforward impression of what will be described in detail in the following sections TODO Write a full example for these coding standards lt php gt 1 1 2 File Format Use UTF 8 character encoding for the codes Lines must end only with a line feed LF Do not use carriage returns CR like Macintosh OS do or the carriage return line feed combination CRLF like Windows OS does There should be one line feed after the closing PHP tag gt at the end of file Vim would do this automatically and there is no need for adding an extra line 1 1 3 Coding Style No spaces on a blank line No trailing spaces at the end of line No extra blank line at the end of file Add proper blank line to separate different logic Break a long line into several short lines It is recommended that lines should be no more than 80 columns This could increase the readability as 80 is just the length of lines in old text mode Only English character is allowed in the code including the comments except for the localization strings Align assignment and parameters in function call when possible ShnfuCarver Documentation Release 1 0 lt php Sresult Sthis gt callSomeFunction paraml second true Ssecond_result this gt callSomeOtherFunction paramete
18. ities Each service contains a name and the real object A ServiceRepository is responsible for handling the services One could retrieve a service by its name from the repository 3 2 2 Manager The Manager is the most important part of the application Manager could have daughter managers The top most manager is the AppManager which holds all other managers All managers are instances of Manager Interface A manager have the following basic methods getName init run clean loadConfig loadAutoload setServiceRepository 16 Chapter 3 ShnfuCarver Design ShnfuCarver Documentation Release 1 0 There may be other common methods that should be added A manager has its own configuration via the name Make sure there are no two managers with the same name A manager may have its own autoload settings All managers share a ServiceRepository instance where the manager could register and retrieve services The manager may make a shortcut method for acquiring the services 3 2 3 Controller All controllers are instances of ControllerInterface The controllers also share a ServiceRepository instance but they should only retrieve services They are not supposed to register services which is the responsibility of managers The controller may also make a shortcut method for acquiring the services 3 3 Framework Components The ShnfuCarver should have the following components e Config e Debug Error Exception e Loader
19. mportant tip special note or a potential hazard Admonitions in sphinx are used for just that There are three kinds of admonitions e tip Tips are used to document or re iterate interesting or important information The content of the directive should be written in complete sentences and include all appropriate punctuation e note Notes are used to document an especially important piece of information The content of the directive should be written in complete sentences and include all appropriate punctuation warning Warnings are used to document potential stumbling blocks or information pertaining to security The content of the directive should be written in complete sentences and include all appropriate punc tuation All admonitions are made the same note Indented and preceded and followed by a blank line Just like a paragraph This text is not part of the note Samples Tip This is a helpful tid bit you probably forgot 5 1 Documentation formatting guide 29 ShnfuCarver Documentation Release 1 0 Note You should pay attention here Warning It could be dangerous See Also Some other information related 30 Chapter 5 About Documentation CHAPTER SIX INDICES AND TABLES 31 ShnfuCarver Documentation Release 1 0 32 Chapter 6 Indices and Tables D doc role 27 P php attr directive 28 php attr role 29 php class directive 27 php
20. n 23 ShnfuCarver Documentation Release 1 0 24 Chapter 4 Shnfu Design CHAPTER FIVE ABOUT DOCUMENTATION 5 1 Documentation formatting guide The shnfu documentation is written with ReST formatted text ReST Re Structured Text is a plain text markup syntax similar to markdown or textile To maintain consistency it is recommended that when adding to the CakePHP documentation you follow the guidelines here on how to format and structure your text 5 1 1 Line length Lines of text should be wrapped at 80 columns The only exception should be long urls and code snippets 5 1 2 Headings and Sections Section headers are created by underlining the title with punctuation characters at least the length of the text e Is used to denote page titles e Is used for sections in a page e Is used for subsections e Is used for sub subsections e Is used for sub sub subsections Headings should not be nested more than 5 levels deep Headings should be preceded and followed by a blank line 5 1 3 Paragraphs Paragraphs are simply blocks of text with all the lines at the same level of indentation Paragraphs should be separated by more than one empty line 5 1 4 Inline markup e one asterisk text for emphasis italics two asterisks text for strong emphasis boldface and e backquotes text for code samples 25 ShnfuCarver Documentation Release 1 0 If asterisks or backquotes appear in running
21. n Release 1 0 3 3 6 Model The Model represents the business logic of the application The model can use a third party library to communicate with the database 3 3 7 Log Log may be an instance of Model Writing a log is done by a controller s action The Log module deals with log information with log level Which levels written to log could be customized by the application The log should be located on some permanent storage by the Model serialization A database is a good way to hold the log The log style is like the following Time Level Information 2012 03 21 09 23 50 Warning Unauthorized access to user info 2012 04 01 18 07 24 Error Could not link to database Detailed information of the above table e Date and time e Log level e Log information e Module which invoke the log e Code file path and line of the log e Any more information not included above could be merged into the Information column Log level includes e Debug Some debug information for the developers This won t appear in a production release Notice Just common information about what happened e Warning Something not in right state but could not endanger the system e Error Error happened and the system may not work properly e Fatal Fatal error happened and not recoverable The system may be shut down 3 4 Application Hierarchy This is a typical application structure tree ShnfuCa
22. r2 third false Slast_result Sthis gt callSomeFunction 73 verrrrrrylong true 2 gt 1 1 4 Coding Method e Always use long tags lt php gt instead of short tags lt gt e Perl shell style comments are discouraged The constructor should mainly include class initialization Do not put in too much action Do not use PHP code e g echo or print to output the html tag e Use instead of if possible e Do not use magic numbers e Do not do exact comparison between float numbers e Avoid embedded assignment This could lead to misunderstanding e Use single quotes for strings if no variable expansion e Put each class in a single file Use namespace for clear naming especially for library e Try not to create global variables which may enhance the relation of modules and introduce unexpected behav ior e Do not use parentheses for statements require_once include echo return e Code must be E STRICT compatible This means that it must not produce any warnings or errors when PHP s error reporting level is set to E_ALL E_STRICT or E ALL in PHP 5 4 x 1 1 5 Including Files When unconditionally including a class or library file use require_once When conditionally including a class file for example factory methods use include_once Either of these will ensure that class files are included only once They share the same file list so a file included by require_once will
23. re Describe a static method its arguments return value and exceptions see php met hod for options php attr name Describe an property attribute on a class Cross Referencing The following roles refer to php objects and links are generated if a matching directive is found php func Reference a PHP function php global Reference a global variable whose name has prefix php const Reference either a global constant or a class constant Class constants should be preceded by the owning class DateTime has an php const DateTime ATOM constant php class Reference a class by name php class ClassName 28 Chapter 5 About Documentation ShnfuCarver Documentation Release 1 0 php meth Reference a method of a class This role supports both kinds of methods php meth DateTime setDate php meth Classname staticMethod php attr Reference a property on an object php attr ClassName SpropertyName php exc Reference an exception 5 1 9 Source code Literal code blocks are created by ending a paragraph with The literal block must be indented and like all paragraphs be separated by single lines This is a paragraph while i doStuff This is regular text again Literal text is not modified or formatted save that one level of indentation is removed 5 1 10 Notes and warnings There are often times when you want to inform the reader of an i
24. rver Project Public Applicationl Webroot index php Application Application php Config Manager 20 Chapter 3 ShnfuCarver Design ShnfuCarver Documentation Release 1 0 gt Fret Config Controller View Model Second Application2 Application3 Library ShnfuCarver Plugin ThirdPartyl Component Manager ThirdParty2 Component Manager The library is the main directory of the ShnfuCarver framework Plugin exists under root directory It contains some third party libraries It could provide some extra functionality to the ShnfuCarver Different applications can be maintained under the same project Each application has its own configuration There might be a Public directory which could be shared among all the applications Note This hierarchy is not required but suggested It can still be customized with the configuration 3 4 Application Hierarchy 21 ShnfuCarver Documentation Release 1 0 22 Chapter 3 ShnfuCarver Design CHAPTER FOUR SHNFU DESIGN This page is not supposed to be here Move it to the proper place when ready Maximum the usage of AJAX i e the request page is mostly a static page All dynamic requests and responses are transfered through AJAX Try to minimize the number of requests in order to reduce the server s burde
25. s This could make the code more flexible and maintainable 3 1 2 Front Controller Pattern ShnfuCarver uses the front controller pattern index php is often used as the front controller All dynamic URI requests are passed to and dispatched by index php The rewrite trick could be used to hide the index php in the URI Of course script with other name is also fine e g while the directory index is set to the static page index html then the front controller could be do php or some page else while the rewrite trick is still powerful for rearranging the URI In the front controller a typical procedure is like the following lt php define APPLICATION PATH realpath __DIR__ require once APPLICATION PATH Application Application php 15 ShnfuCarver Documentation Release 1 0 Sapplication new AppManager Sapplication gt main ne 3 1 3 Active Record Pattern Active record is an approach to accessing data in a database There is no need to developing a new library Just test some third party libraries and choose a suitable one It will not affect the kernel component of the framework Here are some choices 3 2 Kernel Architecture The various functionalities are provided by Service The basic component of application is Manager Controller is the process unit for a single request Doctrine Propel NotORM 3 2 1 Service The Service is the way of invoking various functional
26. ting too long control structures A too long control structure may imply a bad design It s better that it could fit in a single page which is easy for human to read Long control condition could be split into several lines with the logical operators amp amp Il etc at the beginning of the line However the long statement of the control condition is not encouraged Break it into short ones if possible lt php This is too long if Sconditionl Scondition2 amp amp Scondition3 amp amp Scondition4 This looks much better Sis_foo Sconditionl Scondition2 Sis_bar Scondition3 amp amp Scondition4 if Sis_foo amp amp Sis_bar od 1 1 PHP Coding Standards 5 ShnfuCarver Documentation Release 1 0 Condition An example lt php if expr_1 expr_2 action 1 elseif expr 3 amp amp expr 4 action 2 else default action gt Switch There must be a default statement dealing with default situation If it is not necessary also write it following with an immediate break lt php switch condition case 1 actionl break case 2 action2 break default defaultaction break Ternary Operator A complicated condition could be enclosed in parentheses Break down too long lines put the question mark and colon aligned at the front lt php Sa Sconditionl foo Sbar Sb Scondition2 amp amp
Download Pdf Manuals
Related Search
Related Contents
マルチカード対応 食堂決済システム Comedor X Instruction Manual La Mutuelle rassemblée TSG416 Service Manual Rev0 - EDI Ford Industrial Engine ZebraDesigner User Guide - Gold Label Technology Limited Giant CP218 User's Manual - Supprimer la nage à contre courant à la fin de la baignade pour Dataflex ViewMate Ecoline Monitor Arm 212 Copyright © All rights reserved.
Failed to retrieve file