CN112395843A - PHP code-based service processing method, device, equipment and medium - Google Patents

PHP code-based service processing method, device, equipment and medium Download PDF

Info

Publication number
CN112395843A
CN112395843A CN202011279612.0A CN202011279612A CN112395843A CN 112395843 A CN112395843 A CN 112395843A CN 202011279612 A CN202011279612 A CN 202011279612A CN 112395843 A CN112395843 A CN 112395843A
Authority
CN
China
Prior art keywords
annotation
preset
annotation information
information
execution
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202011279612.0A
Other languages
Chinese (zh)
Other versions
CN112395843B (en
Inventor
夏玮
范渊
苗春雨
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Dbappsecurity Technology Co Ltd
Original Assignee
Hangzhou Dbappsecurity Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Dbappsecurity Technology Co Ltd filed Critical Hangzhou Dbappsecurity Technology Co Ltd
Priority to CN202011279612.0A priority Critical patent/CN112395843B/en
Publication of CN112395843A publication Critical patent/CN112395843A/en
Application granted granted Critical
Publication of CN112395843B publication Critical patent/CN112395843B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/169Annotation, e.g. comment data or footnotes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • G06F16/986Document structures and storage, e.g. HTML extensions

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Data Mining & Analysis (AREA)
  • Devices For Executing Special Programs (AREA)
  • Document Processing Apparatus (AREA)

Abstract

The application discloses a PHP code-based service processing method, a device and equipment and a storage medium, wherein the method comprises the following steps: after a service request sent by a client is obtained, an execution method for responding to the service request is searched in a PHP source code; detecting whether pre-written preset annotation information exists in the execution method; if the preset annotation information exists, converting the preset annotation information into target annotation information of a standard data structure; and executing preset service logic by using an executor according to the target annotation information so as to respond to the service request. According to the method and the device, the built-in comment information can be provided to replace a lead plate code for realizing the auxiliary function, the comment information is acquired from the source code during actual execution, the actuator is used for executing the preset service logic to realize the corresponding auxiliary function, the auxiliary function code is separated from the source code, the problem of coupling between the service code and the auxiliary function code is effectively solved, the project logic is clear, and the readability of the code is improved.

Description

PHP code-based service processing method, device, equipment and medium
Technical Field
The present application relates to the field of computer software technologies, and in particular, to a service processing method and apparatus based on a PHP code, an electronic device, and a computer-readable storage medium.
Background
PHP (Hypertext Preprocessor, Hypertext preprocessing language) is a script language that is executed at a server side and embedded in an HTML document. PHP authorities do not provide JAVA-like annotation functionality, but only PHPDOC to generate annotations to documents. PHPDOC is a formal standard for annotating PHP code to help the integrated development environment understand variable types and other ambiguities in weakly typed languages and to provide improved code completion type hints and debugging functionality. Because of no built-in meta-annotation and annotation concept, the open source framework of the mainstream rarely uses annotation to design functions, so that the coupling degree of auxiliary codes and business codes in PHP codes is high, the PHP codes cannot be effectively managed and reasonably multiplexed, the project becomes bloated, and the readability is reduced.
Therefore, how to solve the above problems is a great concern for those skilled in the art.
Disclosure of Invention
The application aims to provide a PHP code-based business processing method and device, an electronic device and a computer-readable storage medium, which solve the problem of coupling between a business code and an auxiliary function code and improve the readability of the code.
In order to achieve the above object, the present application provides a service processing method based on a PHP code, including:
after a service request sent by a client is acquired, searching an execution method for responding to the service request in a PHP source code;
detecting whether pre-written preset annotation information exists in the execution method;
if the preset annotation information exists in the execution method, converting the preset annotation information into target annotation information of a standard data structure;
and executing preset service logic by using a corresponding actuator according to the target annotation information so as to respond to the service request.
Optionally, the detecting whether the pre-written preset annotation information exists in the execution method includes:
and identifying whether the pre-written preset annotation information exists in the source code corresponding to the execution method through a PHP reflection mechanism or a C language lexical method.
Optionally, the converting the preset annotation information into target annotation information of a standard data structure includes:
carrying out validity verification on the annotation parameters and the annotation connection point positions in the preset annotation information;
if the validity is verified, obtaining valid content and associated context information in the preset annotation information;
converting the valid content and the context information into target annotation information of a standard data structure, the target annotation information comprising: the name of the class of the annotation modifier, the name of the method of the annotation modifier, the name of the class of the annotation definition, and the annotation parameter.
Optionally, before the validity verification is performed on the annotation parameter and the annotation connection point in the preset annotation information, the method further includes:
searching whether analyzed annotation content exists in an annotation cache according to the identification information of the preset annotation information; the annotation buffer is used for storing analyzed preset annotation information and context information;
if not, executing the step of verifying the effectiveness of the annotation parameters and the positions of the annotation connecting points in the preset annotation information;
and if so, directly acquiring the target annotation information corresponding to the preset annotation information.
Optionally, the executing, according to the target annotation information, a preset service logic by using a corresponding executor includes:
acquiring basic annotation keywords in the target annotation information, wherein the basic annotation keywords comprise: the system comprises a first class of keywords used for defining execution before/after the method of the annotation modification, a second class of keywords used for defining execution after the method of the annotation modification returns a preset value, and a third class of keywords used for defining execution after the method of the annotation modification throws an exception;
and executing preset service logic at a designated method connection point by using a corresponding actuator according to the target annotation information and the basic annotation key words.
Optionally, the method further includes:
and acquiring a custom annotation class written by a management background and a corresponding custom executor so as to realize the extended service function corresponding to the custom annotation class.
In order to achieve the above object, the present application provides a service processing apparatus based on a PHP code, including:
the method searching module is used for searching an execution method for responding to the service request in the PHP source code after the service request sent by the client is obtained;
the annotation detection module is used for detecting whether pre-written preset annotation information exists in the execution method;
the annotation conversion module is used for converting the preset annotation information into target annotation information of a standard data structure if the preset annotation information exists in the execution method;
and the logic execution module is used for executing preset service logic by using a corresponding actuator according to the target annotation information so as to respond to the service request.
Optionally, the logic execution module includes:
an obtaining unit, configured to obtain a basic annotation keyword in the target annotation information, where the basic annotation keyword includes: the system comprises a first class of keywords used for defining execution before/after the method of the annotation modification, a second class of keywords used for defining execution after the method of the annotation modification returns a preset value, and a third class of keywords used for defining execution after the method of the annotation modification throws an exception;
and the execution unit is used for executing preset service logic at a designated method connection point by using a corresponding actuator according to the target annotation information and the basic annotation key words.
To achieve the above object, the present application provides an electronic device including:
a memory for storing a computer program;
a processor for implementing the steps of any of the aforementioned disclosed PHP code-based service processing methods when executing the computer program.
To achieve the above object, the present application provides a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the steps of any of the PHP code-based service processing methods disclosed in the foregoing.
According to the above scheme, the service processing method based on the PHP code provided by the present application includes: after a service request sent by a client is acquired, searching an execution method for responding to the service request in a PHP source code; detecting whether pre-written preset annotation information exists in the execution method; if the preset annotation information exists in the execution method, converting the preset annotation information into target annotation information of a standard data structure; and executing preset service logic by using a corresponding actuator according to the target annotation information so as to respond to the service request. According to the method and the device, the built-in comment information can be provided to replace the lead plate code for realizing the auxiliary function, the comment information is acquired from the source code during actual execution, the actuator is used for executing the preset service logic to realize the corresponding auxiliary function, the auxiliary function code is separated from the source code, the problem of coupling between the service code and the auxiliary function code is effectively solved, the project logic is clear, and the readability of the code is improved.
The application also discloses a PHP code-based service processing device, an electronic device and a computer-readable storage medium, which can also realize the technical effects.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a service processing method based on PHP codes disclosed in an embodiment of the present application;
fig. 2 is a flowchart of a specific PHP code-based service processing method disclosed in an embodiment of the present application;
fig. 3 is a structural diagram of a service processing apparatus based on a PHP code disclosed in an embodiment of the present application;
fig. 4 is a block diagram of an electronic device disclosed in an embodiment of the present application;
fig. 5 is a block diagram of another electronic device disclosed in the embodiments of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In the prior art, a PHP official does not provide a JAVA-like annotation function, and only provides PHPDOC for generating a document annotation, so that the PHP code has high coupling degree of an auxiliary code and a service code, and cannot be effectively managed and reasonably reused, so that a project becomes bloated and the readability is reduced.
Therefore, the embodiment of the application discloses a PHP code-based business processing method, which solves the coupling problem between the business code and the auxiliary function code and improves the readability of the code.
Referring to fig. 1, a service processing method based on a PHP code disclosed in the embodiment of the present application includes:
s101: after a service request sent by a client is acquired, searching an execution method for responding to the service request in a PHP source code;
in the embodiment of the application, a service request sent by a client can be received, and after the request is obtained, an execution method for responding to the current service request is searched from the PHP source code. For example, if a user sends a request to a hundred degree server, the method for searching is looked up in the source code.
S102: detecting whether pre-written preset annotation information exists in the execution method;
in this step, it may be detected whether the source code corresponding to the execution method has pre-programmed pre-annotation information. Specifically, whether pre-written preset annotation information exists in the source code corresponding to the execution method can be identified through a PHP reflection mechanism or a C language lexical method.
S103: if the preset annotation information exists in the execution method, converting the preset annotation information into target annotation information of a standard data structure;
if the preset annotation information is detected to exist in the execution method in the above steps, the preset annotation information can be converted into the target annotation information of the standard data structure.
In a specific implementation, the converting the preset annotation information into the target annotation information of the standard data structure may include: carrying out validity verification on the annotation parameters and the annotation connection point positions in the preset annotation information; if the validity is verified, obtaining valid content and associated context information in the preset annotation information; converting the effective content and the context information into target annotation information of a standard data structure, wherein the target annotation information may include but is not limited to: the name of the class of the annotation modifier, the name of the method of the annotation modifier, the name of the class of the annotation definition, and the annotation parameter.
As a preferred embodiment, in order to avoid repeated parsing of the annotation information, before validity verification is performed on the annotation parameter and the annotation connection point position in the preset annotation information, first, according to the identification information of the preset annotation information, whether parsed annotation content exists or not is searched in an annotation buffer; the annotation buffer is used for storing the analyzed preset annotation information and the context information; if the analyzed annotation content does not exist in the annotation buffer, the step of verifying the effectiveness of the annotation parameter and the annotation connection point position in the preset annotation information is continuously executed; and if the analyzed annotation content exists in the annotation buffer, directly acquiring target annotation information corresponding to the preset annotation information. That is, after the annotation information is analyzed each time, the annotation information can be stored in the annotation buffer, and subsequently, before the annotation information is analyzed, whether the annotation information is analyzed or not can be searched in the annotation buffer, and if the annotation information is analyzed, the information analyzed before can be utilized without repeated analysis.
S104: and executing preset service logic by using a corresponding actuator according to the target annotation information so as to respond to the service request.
It can be understood that after the target annotation information in the standard data format is obtained, the corresponding executor may be used to execute the preset service logic according to the target annotation information, so as to implement the corresponding auxiliary function, and finally perform the corresponding service request. Specifically, one piece of annotation information corresponds to one executor, and the executor is used for executing a defined service logic, or may not be implemented logically. If no logic implementation is performed, that is, the service logic of the executor is not defined, a null logic operation is performed, and the representation and annotation is a section of common interpretation text. For example, if there is a piece of comment information @ output, and after mapping to a corresponding executor, the executor may define an operation logic as "print 'XX'", then the content defining 'XX' may be obtained in the comment information to execute the corresponding output logic. If no operation logic is defined in the executor, the annotation information is a piece of text interpretation information.
Specifically, the process of executing the preset service logic by using the corresponding executor according to the target annotation information may include: obtaining basic annotation keywords in the target annotation information, wherein the basic annotation keywords can include but are not limited to: the system comprises a first class of keywords used for defining execution before/after the method of the annotation modification, a second class of keywords used for defining execution after the method of the annotation modification returns a preset value, and a third class of keywords used for defining execution after the method of the annotation modification throws an exception; and executing preset service logic at the designated method connection point by using a corresponding actuator according to the target annotation information and the basic annotation key words.
In a preferred embodiment, the present embodiment can also perform custom extension on the annotation. For example, a custom annotation class written by the management background and a corresponding custom executor can be obtained, so as to implement an extended service function corresponding to the custom annotation class.
According to the above scheme, the service processing method based on the PHP code provided by the present application includes: after a service request sent by a client is acquired, searching an execution method for responding to the service request in a PHP source code; detecting whether pre-written preset annotation information exists in the execution method; if the preset annotation information exists in the execution method, converting the preset annotation information into target annotation information of a standard data structure; and executing preset service logic by using a corresponding actuator according to the target annotation information so as to respond to the service request. According to the method and the device, the built-in comment information can be provided to replace the lead plate code for realizing the auxiliary function, the comment information is acquired from the source code during actual execution, the actuator is used for executing the preset service logic to realize the corresponding auxiliary function, the auxiliary function code is separated from the source code, the problem of coupling between the service code and the auxiliary function code is effectively solved, the project logic is clear, and the readability of the code is improved.
The PHP code-based service processing method provided in the embodiments of the present application is introduced below through a specific implementation scenario. Referring to fig. 2, in particular, the present embodiment defines an interceptor in advance for acquiring the annotation information in the source code. After a service request sent by a client is obtained, an interceptor can be used for positioning an execution class and a corresponding method according to a request route, and obtaining annotation information in the execution class and the corresponding method. When the annotation information is obtained, the mode of obtaining the annotation can be selected through the compatibility of the adapter mode and the support of the three-party native annotation extension. For example, the support of annotation can be added in the C language lexical analysis by using self-research or three-party PHP extension to improve the analysis performance of the code, and the interceptor can acquire annotation information in the source code by means of C language lexical recognition or reflection mechanism recognition of the PHP. The PHP reflection mechanism specifically includes a set of API (Application Program Interface) that adds the ability to reverse engineer classes, interfaces, functions, methods, and extensions, and provides methods for retrieving document annotations in functions, classes, and methods.
After the annotation information is obtained, the annotation content may be converted into a unified data structure using a parser for interfacing with the actuator. In particular implementations, the parser may include three core components: the checker is used for verifying the validity of the annotation parameter and whether the position of the annotation connecting point is valid; the core analyzer is used for acquiring the effective content of the annotation and the associated context information; and an annotation buffer for storing the parsed annotations and their context information, avoiding duplicate parsing. The annotation content of the unified standard data structure may specifically include: the name of the class of the annotation modifier, the name of the method of the annotation modifier, the name of the class of the annotation definition, and the parameters of the annotation.
And when the parser outputs the converted annotation information of the unified standard data structure to the executor, the executor performs corresponding service logic processing. It is noted that it is the responsibility of the enforcer to handle the service that the annotation is to replace. The default execution logic may be preset or may not be implemented. The method implementation may be inherited or rewritten. As an alternative embodiment, the user may implement the executor by himself, and a specific executor is designated to process a specific service through parameter introduction.
It should be noted that, in a specific application level, the basic annotation keyword is defined for the method-level connection point, and specifically, the basic annotation keyword may be in a format of "@" plus an annotation name. The connection point is a concept in AOP (Aspect Oriented Programming), and specifically refers to an execution point of a program, which may act on classes, methods, parameters, attributes, and the like. The base annotation keywords may include, but are not limited to: @ before: performed prior to annotating the decorated method; @ after: executed after annotating the decorated method; @ success: executing when the method for annotating the embellishment returns true; @ failed: execute when the method of annotation modification returns false or null; @ except: when the method for annotating the decoration throws exception, the execution is carried out. The basic annotation keywords can be applied to scenes such as entry verification, exit formatting, exception handling, log recording and the like.
Further, the present embodiment may also provide a function of extending the custom annotation. That is, the user can construct the annotation class according to the self service requirement, and set the custom attribute and the semantic meaning. If the used annotation is not consistent with the PHPDOC format, the parser can be realized by itself to obtain annotation information in the annotation, the processing logic in the executor is designed to complete the function of the annotation to be replaced, and finally, the self-defined annotation keyword is used on the source code method.
In the embodiment of the application, the PHP code is reconstructed based on the AOP programming idea, and the built-in comment information is used for replacing the lead plate code, so that research personnel only need to pay attention to the service logic, and the auxiliary code is stripped from the service logic, so that unified management and maintenance are facilitated, repeated codes are reduced, and coupling with specific auxiliary service realization is avoided. Meanwhile, the method is compatible with support of three-party extension or future official extension through adaptation, the possibility of improvement on the operation performance is provided, and good functional universality and expandability are achieved.
In the following, a service processing apparatus based on a PHP code provided in an embodiment of the present application is introduced, and a service processing apparatus based on a PHP code described below and a service processing method based on a PHP code described above may be referred to each other.
Referring to fig. 3, a service processing apparatus based on a PHP code provided in an embodiment of the present application includes:
the method searching module 201 is configured to search, after acquiring a service request sent by a client, an execution method for responding to the service request in a PHP source code;
the annotation detection module 202 is configured to detect whether pre-written preset annotation information exists in the execution method;
the annotation conversion module 203 is configured to convert the preset annotation information into target annotation information of a standard data structure if the preset annotation information exists in the execution method;
and the logic execution module 204 is configured to execute a preset service logic by using a corresponding actuator according to the target annotation information, so as to respond to the service request.
For the specific implementation process of the modules 201 to 204, reference may be made to the corresponding content disclosed in the foregoing embodiments, and details are not repeated here.
On the basis of the foregoing embodiment, as a preferred implementation manner, the logic execution module 204 in this embodiment may specifically include:
an obtaining unit, configured to obtain a basic annotation keyword in the target annotation information, where the basic annotation keyword includes: the system comprises a first class of keywords used for defining execution before/after the method of the annotation modification, a second class of keywords used for defining execution after the method of the annotation modification returns a preset value, and a third class of keywords used for defining execution after the method of the annotation modification throws an exception;
and the execution unit is used for executing preset service logic at a designated method connection point by using a corresponding actuator according to the target annotation information and the basic annotation key words.
The present application further provides an electronic device, and as shown in fig. 4, an electronic device provided in an embodiment of the present application includes:
a memory 100 for storing a computer program;
the processor 200, when executing the computer program, may implement the steps provided by the above embodiments.
Specifically, the memory 100 includes a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and computer-readable instructions, and the internal memory provides an environment for the operating system and the computer-readable instructions in the non-volatile storage medium to run. The processor 200 may be a Central Processing Unit (CPU), a controller, a microcontroller, a microprocessor or other data Processing chip in some embodiments, and provides computing and controlling capabilities for the electronic device, and when executing the computer program stored in the memory 100, the PHP code-based service Processing method disclosed in any of the foregoing embodiments may be implemented.
On the basis of the above embodiment, as a preferred implementation, referring to fig. 5, the electronic device further includes:
and an input interface 300 connected to the processor 200, for acquiring computer programs, parameters and instructions imported from the outside, and storing the computer programs, parameters and instructions into the memory 100 under the control of the processor 200. The input interface 300 may be connected to an input device for receiving parameters or instructions manually input by a user. The input device may be a touch layer covered on a display screen, or a button, a track ball or a touch pad arranged on a terminal shell, or a keyboard, a touch pad or a mouse, etc.
And a display unit 400 connected to the processor 200 for displaying data processed by the processor 200 and for displaying a visualized user interface. The display unit 400 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch panel, or the like.
And a network port 500 connected to the processor 200 for performing communication connection with each external terminal device. The communication technology adopted by the communication connection can be a wired communication technology or a wireless communication technology, such as a mobile high definition link (MHL) technology, a Universal Serial Bus (USB), a High Definition Multimedia Interface (HDMI), a wireless fidelity (WiFi), a bluetooth communication technology, a low power consumption bluetooth communication technology, an ieee802.11 s-based communication technology, and the like.
While FIG. 5 shows only an electronic device having the assembly 100 and 500, those skilled in the art will appreciate that the configuration shown in FIG. 5 does not constitute a limitation of the electronic device, and may include fewer or more components than shown, or some components may be combined, or a different arrangement of components.
The present application also provides a computer-readable storage medium, which may include: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk. The storage medium stores thereon a computer program, which when executed by a processor implements the PHP code-based service processing method disclosed in any of the foregoing embodiments.
According to the method and the device, the built-in comment information can be provided to replace a lead plate code for realizing the auxiliary function, the comment information is acquired from the source code during actual execution, the actuator is used for executing the preset service logic, the corresponding auxiliary function is realized, the auxiliary function code is separated from the source code, the problem of coupling between the service code and the auxiliary function code is effectively solved, the project logic is clear, and the readability of the code is improved.
The embodiments are described in a progressive manner in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. For the system disclosed by the embodiment, the description is relatively simple because the system corresponds to the method disclosed by the embodiment, and the relevant points can be referred to the method part for description. It should be noted that, for those skilled in the art, it is possible to make several improvements and modifications to the present application without departing from the principle of the present application, and such improvements and modifications also fall within the scope of the claims of the present application.
It is further noted that, in the present specification, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.

Claims (10)

1. A PHP code-based service processing method is characterized by comprising the following steps:
after a service request sent by a client is acquired, searching an execution method for responding to the service request in a PHP source code;
detecting whether pre-written preset annotation information exists in the execution method;
if the preset annotation information exists in the execution method, converting the preset annotation information into target annotation information of a standard data structure;
and executing preset service logic by using a corresponding actuator according to the target annotation information so as to respond to the service request.
2. The traffic processing method according to claim 1, wherein the detecting whether pre-written pre-annotation information exists in the execution method comprises:
and identifying whether the pre-written preset annotation information exists in the source code corresponding to the execution method through a PHP reflection mechanism or a C language lexical method.
3. The business processing method of claim 1, wherein the converting the preset annotation information into the target annotation information of a standard data structure comprises:
carrying out validity verification on the annotation parameters and the annotation connection point positions in the preset annotation information;
if the validity is verified, obtaining valid content and associated context information in the preset annotation information;
converting the valid content and the context information into target annotation information of a standard data structure, the target annotation information comprising: the name of the class of the annotation modifier, the name of the method of the annotation modifier, the name of the class of the annotation definition, and the annotation parameter.
4. The business processing method according to claim 3, wherein before the validity verification of the annotation parameter and the annotation connection point in the preset annotation information, the method further comprises:
searching whether analyzed annotation content exists in an annotation cache according to the identification information of the preset annotation information; the annotation buffer is used for storing analyzed preset annotation information and context information;
if not, executing the step of verifying the effectiveness of the annotation parameters and the positions of the annotation connecting points in the preset annotation information;
and if so, directly acquiring the target annotation information corresponding to the preset annotation information.
5. The business processing method according to any one of claims 1 to 4, wherein the executing, according to the target annotation information, a preset business logic by using a corresponding executor comprises:
acquiring basic annotation keywords in the target annotation information, wherein the basic annotation keywords comprise: the system comprises a first class of keywords used for defining execution before/after the method of the annotation modification, a second class of keywords used for defining execution after the method of the annotation modification returns a preset value, and a third class of keywords used for defining execution after the method of the annotation modification throws an exception;
and executing preset service logic at a designated method connection point by using a corresponding actuator according to the target annotation information and the basic annotation key words.
6. The traffic processing method according to claim 5, further comprising:
and acquiring a custom annotation class written by a management background and a corresponding custom executor so as to realize the extended service function corresponding to the custom annotation class.
7. A service processing apparatus based on PHP code, comprising:
the method searching module is used for searching an execution method for responding to the service request in the PHP source code after the service request sent by the client is obtained;
the annotation detection module is used for detecting whether pre-written preset annotation information exists in the execution method;
the annotation conversion module is used for converting the preset annotation information into target annotation information of a standard data structure if the preset annotation information exists in the execution method;
and the logic execution module is used for executing preset service logic by using a corresponding actuator according to the target annotation information so as to respond to the service request.
8. The traffic processing apparatus of claim 7, wherein the logic execution module comprises:
an obtaining unit, configured to obtain a basic annotation keyword in the target annotation information, where the basic annotation keyword includes: the system comprises a first class of keywords used for defining execution before/after the method of the annotation modification, a second class of keywords used for defining execution after the method of the annotation modification returns a preset value, and a third class of keywords used for defining execution after the method of the annotation modification throws an exception;
and the execution unit is used for executing preset service logic at a designated method connection point by using a corresponding actuator according to the target annotation information and the basic annotation key words.
9. An electronic device, comprising:
a memory for storing a computer program;
a processor for implementing the steps of the PHP code based service processing method according to any one of claims 1 to 6 when executing the computer program.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored thereon a computer program which, when being executed by a processor, implements the steps of the PHP code-based service processing method according to any one of claims 1 to 6.
CN202011279612.0A 2020-11-16 2020-11-16 PHP code-based service processing method, device and medium Active CN112395843B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011279612.0A CN112395843B (en) 2020-11-16 2020-11-16 PHP code-based service processing method, device and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011279612.0A CN112395843B (en) 2020-11-16 2020-11-16 PHP code-based service processing method, device and medium

Publications (2)

Publication Number Publication Date
CN112395843A true CN112395843A (en) 2021-02-23
CN112395843B CN112395843B (en) 2024-04-09

Family

ID=74600462

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011279612.0A Active CN112395843B (en) 2020-11-16 2020-11-16 PHP code-based service processing method, device and medium

Country Status (1)

Country Link
CN (1) CN112395843B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112988593A (en) * 2021-04-13 2021-06-18 苏州沁游网络科技有限公司 Code analysis method and device, computer equipment and storage medium
CN113157721A (en) * 2021-03-03 2021-07-23 北京中安星云软件技术有限公司 Method for realizing association of application access and database access behaviors based on PHP (hypertext preprocessor) extended PDO (product data object)
CN113434582A (en) * 2021-06-24 2021-09-24 平安国际智慧城市科技股份有限公司 Service data processing method and device, computer equipment and storage medium
CN115629762A (en) * 2022-10-11 2023-01-20 北京远舢智能科技有限公司 JSON data processing method and device, electronic equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106919434A (en) * 2017-03-22 2017-07-04 恒生电子股份有限公司 A kind of code generating method and device
CN110716798A (en) * 2019-09-29 2020-01-21 微梦创科网络科技(中国)有限公司 PHP (hypertext preprocessor) timing task management method and system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106919434A (en) * 2017-03-22 2017-07-04 恒生电子股份有限公司 A kind of code generating method and device
CN110716798A (en) * 2019-09-29 2020-01-21 微梦创科网络科技(中国)有限公司 PHP (hypertext preprocessor) timing task management method and system

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113157721A (en) * 2021-03-03 2021-07-23 北京中安星云软件技术有限公司 Method for realizing association of application access and database access behaviors based on PHP (hypertext preprocessor) extended PDO (product data object)
CN112988593A (en) * 2021-04-13 2021-06-18 苏州沁游网络科技有限公司 Code analysis method and device, computer equipment and storage medium
CN112988593B (en) * 2021-04-13 2024-02-06 苏州沁游网络科技有限公司 Code analysis method, device, computer equipment and storage medium
CN113434582A (en) * 2021-06-24 2021-09-24 平安国际智慧城市科技股份有限公司 Service data processing method and device, computer equipment and storage medium
CN115629762A (en) * 2022-10-11 2023-01-20 北京远舢智能科技有限公司 JSON data processing method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN112395843B (en) 2024-04-09

Similar Documents

Publication Publication Date Title
CN112395843B (en) PHP code-based service processing method, device and medium
WO2021017735A1 (en) Smart contract formal verification method, electronic apparatus and storage medium
EP2368189B1 (en) Debugging pipeline
US7634720B2 (en) System and method for providing context to an input method
US8543913B2 (en) Identifying and using textual widgets
CA2684822C (en) Data transformation based on a technical design document
JP4420968B2 (en) Method and computer-readable medium for commanding
JP5655056B2 (en) A program for distributing dictionaries
KR100692172B1 (en) Universal string analyzer and method thereof
CN101751281A (en) System and method for generating compiler
US20080016488A1 (en) Output styling in an IDE console
US20150106701A1 (en) Input support method and information processing system
US20110276950A1 (en) Name binding extensibility for typed programming language
CN114398673A (en) Application compliance detection method and device, storage medium and electronic equipment
CN111078228A (en) Method and device for converting webpage into small program, server and storage medium
CN113778897A (en) Automatic test method, device, equipment and storage medium of interface
US8434072B2 (en) Automatic retrieval of translated messages for interacting with legacy systems
CN113238739A (en) Plug-in development and data acquisition method, device, electronic equipment and medium
US20060282820A1 (en) COBOL syntax for native XML file parsing and file generation
TW200417924A (en) WIN F-language interpreter
CN112162738B (en) Data conversion method and device, terminal equipment and storage medium
JP2013080386A (en) Information processing device and address management method
US9524307B2 (en) Asynchronous error checking in structured documents
KR20220110323A (en) Auxiliary processing methods, devices, storage media and programs in software development. Products and programs.
CN116501931A (en) Interaction method with graph database and related equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant