Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of PHP Code Specification, process Specification and git Specification

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you the PHP code specification, process specification, git specification example analysis, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!

1. Naming convention

(1)。 Variable naming convention

1. Variables use hump nomenclature to prohibit the use of pinyin or pinyin plus numbers

two。 Variables should also be descriptive and put an end to all naming methods of Pinyin or Pinyin mixed with English.

3. Variable package numbers, letters and underscore characters, other characters are not allowed. It is best to use English abbreviations that can be found in the project. You can use forms that are easy to understand at a glance.

4. Variables begin with letters. If variables pack multiple words, the first letter is lowercase. When multiple words are packaged, the first letter of each subsequent word is capitalized. For example: $itSports

5. Variables are named using valid names

For example, comment: $commentArr

6. Variable attributes are clearly marked

For example, the array variable is followed by Arr: $commentArr, and the value: $commentInt

7. Variables are allowed but discouraged from using nondescriptive letters as variable names except in the loop body (for,foreach,while).

For example: $iGraine.

(2)。 Constant naming convention

1. Constant names should be descriptive and put an end to all naming methods of Pinyin or Pinyin mixed with English.

two。 Constant names package alphabetic characters and underscores, numbers and other characters are not allowed.

The built-in values of 3.PHP TRUE, FALSE, and NULL must all be written in uppercase letters.

4. All letters of constant names must be capitalized and, in a few cases, underscores can be used to separate words.

For example: define ('AAA_BBB_CCC',' true'); (if the constant name consists of aaa, bbb, and ccc)

Define ('NAME','root')

(3)。 Naming convention for class names

1. A class is declared in a file, and the class name string must be included in the file name, which is not only easy to find, but also helpful to automatically load the class in the program.

two。 Class names should be descriptive and put an end to all naming methods of Pinyin or Pinyin mixed with English.

3. Class names include alphabetic characters, numbers and other characters are not allowed

4. If the class name includes more than one word, hump naming should be used. The first letter of each word must be capitalized and consecutive capitalization is not allowed.

The initials of the class are capitalized such as: class Comment {}

AaaBbbCcc (if the class name consists of aaa, bbb, and ccc)

(4)。 Method naming convention

1. The function name should be descriptive and put an end to all naming methods of Pinyin or Pinyin mixed with English.

two。 Function names include alphabetic characters, and numbers and other characters are not allowed.

3. The first letter of the function name is lowercase, and when wrapping multiple words, the first letter of each subsequent word is capitalized.

For example: aaaBbbCcc (if the function name consists of aaa, bbb, and ccc)

4. The function name should have an action description such as get,set.

Function getUser () {/ / function content} method. The function is effectively named: function getCommentIdByTableName () {}

5. You can declare an underlined form before the name of an image function, indicating that the function is a private method of this class and access is not allowed externally.

For example: function _ func () {}

two。 Code comment

1. Comment format

/ * *

Module-big function-function point or method function

* @ author author

* @ create creation time

* @ param $name

* @ return array

, /

Comments must be made in accordance with specifications

2. Line comment

/ / 1. Mark 1, 2, 3 before line comments.

/ / 2. Briefly explain the purpose of this line of code.

3. The demand is clear

1. The logic is clear

two。 The goal is clear

4. Code statement specification

two。 Save data specification

1. Initialize default properties

2.load load properties save save or modify

3. Logical problems must be dealt with in beforeSave

5. Code submission specification

1. New workflow (the code must be modified on top of the workflow)

two。 Submit the code first, then switch to dev, pull dev, and then enter the workflow and merge it into the workflow.

3. Enter dev and merge the workflow into dev

4. Push to the test environment

5. Code submission format

[my current job] system function-major function-detailed function

For example: [develop] Cloud system-Front desk Home-Edit broadcast Picture

Detailed steps

1. Open your own sourceTree and pull the latest code in dev

two。 Click the top menu "Git Workflow"-> create a new feature-> create it into a folder named after your own name for easy identification. The function name is the name of the feature you made.

3. The creation is completed, for example, the management of the feature/lihuien/ home broadcast graph.

4. When the code is finished, click submit-> on the top menu, and then switch to dev- > dev to pull the latest code-> before switching to the workflow

5. Click dev, and then right-click, "merge dev into current Branch"-> Click

6. Then switch to dev- > right-click Workflow-> "merge Workflow feature/lihuien/ Home broadcast Map Management Code to the current Branch" appears, and click OK

7. Finally, click the top menu "push"-> Select dev- > OK-> switch to your own workflow or create a new workflow for the next feature development.

Tip: if there is a conflict in the submission, please find the corresponding developer in the conflict file to resolve it in time, not without authorization, in case it will introduce junk code into the code base or destroy the functional integrity of your teammates.

6.Teambition task card specification

1. If you finish your daily task, click it in time.

two。 If the task is postponed, the reason for the delay of SD

3. Add task associations if you need the cooperation of others

4. I have to fill out my own task card when I go to work every day.

5. If the task needs to be suspended, write down the reason for the suspension.

6. Write notes clearly, fill in the subtasks, and add a picture description if necessary

Specific format of the task:

[my current job] system function-major function-detailed function

[development] Cloud system-backend-employee list

Note:

1. Modify employee information

two。 List search, etc.

Subtask 1 [Development] employee list-Delete employee-js return prompt

Etc.

7. Prompt return value

Return format when 1.true

`return json_encode (['status'= >' success','message'=' prompt', 'data'= >' requirement data']) `

Return format when 2.false

`return json_encode (['status'= >' error','message'=' prompt', 'data'= >' modification failed (or error message)']) `

two。 Cloud sports environment specification

1. Install softwar

two。 Server: xampp needs to be installed

3. Database: mysql version 5.7 needs to be installed

4. Version control: Git needs to be installed

5.git client: sourceTree needs to be installed

6. Editor: phpStorm needs to be installed with registration code

7. Package management tools: composer needs to be installed

8. Browser: chrome needs to be installed

two。 Development and use environment

1. Editor: phpStorm

two。 Server: xampp (php7.0 version)

3. Database: mysql version 5.7

4. Code repository: coding

5. Version control: Git

6.git client: sourceTree

7. Package Management tool: composer

8. Browser: chrome

3. Team tool

1. Chat tool: bearyChat

two。 Task tool: teambition

3. Code hosting: coding/gitlab

4. Demand account number

1. Tencent enterprise email account

2.coding account number

3.gitHub account number

4.bearyChat account number

5.teambition account number

5. Requirements, prototypes, development

1. If you encounter unintelligible or illogical requirements when understanding requirements or prototypes, please communicate with the corresponding prototypes in time to maintain the consistency between the development and the original.

two。 If you encounter a problem that cannot be solved in time, please communicate with the corresponding developer in time.

6.sourceTree specification

1.Master

The 1.Master branch is an online environment branch

two。 The branch can only be submitted or merged by the administrator

3. Except for administrators, developers are prohibited from operating Master privately.

4. Never submit code directly to that branch

2. Dev

The 1.Dev branch is the system test branch.

two。 Submission to the Dev branch must be a complete functional module.

3. The code needs to be tested and approved by the administrator before it is submitted.

4. Remember not to submit semi-finished or junk code

5. Remember that you can't modify the code directly on the Dev branch, otherwise it will be considered invalid.

6. When you need to develop your own task functionality, create your own feature workflow

3. Feature

The 1.Feature branch is a personal development branch.

two。 This branch is the branch of tasks, functions, and modifying bug.

3. Branch naming must be standardized, such as: feature/lihuien/ public paging class

4. The first thing to do at work is to pull the Dev code into your own workflow to prevent code merge conflicts.

Note:

(1)。 The unfinished code must not be submitted directly to Dev, and the submitted code must follow the specification.

(2)。 The code must be updated every other hour. if there is an uncommitted and undeveloped function, be sure to push it to your remote function branch.

7. Data migration

1. Data migration must be written according to the specification.

two。 Data attributes must be asked clearly, in the increase

3. When you migrate, you must write a rollback file

4. Be sure to test correctly after migration and submit to Dev

Note: be sure to migrate and roll back the test correctly before submitting the code to the code base, otherwise rewrite

Form form in 8.Yii

If the attributes defined during 1.Form form validation are repeated, please use constants after definition to avoid reuse.

These are all the contents of the article "sample Analysis of PHP Code Specification, process Specification, and git Specification". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report