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

What are the interview questions for senior PHP engineers?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly explains "what are the interview questions for senior PHP engineers". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn what are the interview questions for senior PHP engineers.

Question 1. How do you manage the branch of Git?

In the process of using git, I was really overjoyed by its branching function, but it's a double-edged sword, and you'll get this git path map if you're not careful:

My doubt:

So what kind of branching strategy should we use in the team for development collaboration?

In a multi-person team, should we develop directly on the master branch?

What kind of branches should be used to repair bug if it is generated online?

How can testing effectively participate in the testing of each branch when there are multiple branches?

Solve problems with mature workflows

Before answering the above questions, introduce several workflows first, and then answer them through the mode of the workflow. Because we have to be in a certain set of situations in order to discuss the idea of solving the problem.

The following three workflow approaches are all function-driven development, that is, the requirements are generated first, and then the corresponding branches are born, then developed, and finally merged back to complete the mission is deleted.

Git flowGithub flowGitlab flow

For a detailed introduction of these three workflows, it is recommended to take a look at this article-Ruan Yifeng

I am now using Git flow. Through my own practice, it is really easy to use and solve a lot of problems. Then if you find something different from your actual situation, you can make some changes according to your needs.

My choice

I chose Git flow, whose main feature is that it has two branches for a long time:

Main Branch master Development Branch develop

Then, there are three auxiliary branches, all of which are short-term, and half of the cases should only exist locally and should not be submitted to the remote library.

Functional Branch (feature branch) Patch Branch (hotfix branch) pre-issued Branch (release branch)

Recommended naming conventions for the above branches: feature-xxx, release-xxx, hotfix-xxx

Aside: I used to like to use underscores, but later I found that you don't need to press shift to hit the center line. Haha, the era of the middle line begins from now on.

When do you want a functional branch?

When you get a requirement, or a bug fix that is not immediately available, you should open a branch from develop to complete this part of the work. Merge to the develop branch when finished.

When do you want to pre-send the branch?

This branch is prepared for pre-release, and the intervention of testing should only be involved when the branch is generated. When we are almost done whether it is the development of new features or general bug modifications. You should generate a release branch from develop, give it to the test, and modify it directly if there is a bug. When all is done, merge back to develop and merge into master.

I need to say a few more words about this branch. Because this is a very important step, if we use the git hook, when merged into master, it will be automatically published online, so this is the last barrier to launch.

At the same time, it also solves one of my puzzles: how can testing participate in each branch of git? The answer is: the test should not be involved in every branch, only in the release branch. Other development branches should be tested by the developers themselves, and only allowed to be merged into develop when there is no problem with the test, which requires each developer to improve the quality of the products he delivers, how to ensure the quality of the products he delivers? Automated testing is a good choice, okay, stop, this is not our main task today, this topic will talk about another day.

When do you need a patch branch?

The less this situation, the better. Because the reason is: online bug, and must be repaired immediately, no matter where you are, when the phone rings, take out the computer to change the bug.

It is very similar to release, both need to be completed and merged into: master and develop. The difference is that it needs to open a branch from the master.

Note that there is no test intervention here, half of it is a small emergency bug on the code, which is serious, but can be easily changed. Of course, if there are some exceptions, you should let the tests be tested before merging and releasing.

Git development is easy to use, but branches should be used reasonably according to certain rules.

In addition, except for: master and develop branches, no other branches should appear in the remote repository.

Using git must be combined with its various hooks to improve development efficiency. Let's introduce it later here.

Question 2. How is PHP inter-process communication implemented?

Usually, the process communication methods in linux are: message queue, semaphore, shared memory, signal, pipeline, socket.

Message queuing: message queuing is a queue data structure stored in memory.

Semaphore: an atomic operation provided by the system, a semaphore, and only one process can operate it. A process that acquires a semaphore must be released by that process.

Shared memory: a common memory area opened up by the system in memory, which can be accessed by any process, and can be accessed by multiple processes at the same time. In order to ensure data consistency, the memory area needs to be locked or semaphore added.

Signal: a signal is a system call. Usually the kill command we use is to send a signal to a process. Which signals can be viewed by running kill-l in liunx/mac. In the following example, the parent process waits five seconds to send a sigint signal to the child process. The child process captures the signal and drops the signal processing function.

Pipeline: pipeline is a commonly used means of multi-process communication, which is divided into unnamed pipeline and named pipeline. Anonymous pipeline can only be used for inter-process communication with kinship, while named pipeline can be used for any process on the same host. Only famous pipes are introduced here. In the following example, the child process writes the data and the parent process reads the data.

We found that PHP encapsulates semaphores and shared memory very well and is very easy to use. In addition, PHP's class library Sync encapsulates common IPC methods into classes, which can be used across platforms.

3. What are the scenarios of Swoole's cooperative program and php's own yield?

The scene of yield that comes with php:

The co-program can be used in asynchronous network IO to make it non-blocking.

For example, if you are in a http request and you need to request an external interface, there will be the following scenario.

Your front server is nginx,nginx is non-blocking asynchronous, but php-fpm is synchronous blocking. Then when you request the outside interface, the task will be blocked. (add here that php-fpm 's Worker process is synchronously blocked.)

Suppose you use a co-program, so when you request an interface, your task can be paused to save the context. Then, when your interface returns, reset the task to continue. Your process doesn't have to be spent on this task, and you can handle other http requests. Is this a high complication?

Similarly, when your request is querying the database, it is also an IO request, which is also synchronous. The collaboration program can make your IO programming asynchronous and non-blocking, thus increasing your concurrency. This is mainly so that your CPU can handle other things while waiting for IO. All IO requests can do this through a collaborative process.

Thank you for your reading. the above is the content of "what are the interview questions for Senior PHP Engineers". After the study of this article, I believe you have a deeper understanding of what the interview questions of Senior PHP Engineers have, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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

Internet Technology

Wechat

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

12
Report