Home > Backend Development > PHP Tutorial > macos - When developing PHP on Mac, do you use a virtual machine or build the environment directly under Mac?

macos - When developing PHP on Mac, do you use a virtual machine or build the environment directly under Mac?

WBOY
Release: 2023-03-03 09:52:02
Original
1983 people have browsed it

As the title says, I want to do PHP development under mac. I want to see the real-time effect locally, and then deploy it to the server (CentOS) after development, or use SSH to directly connect to the server VIM for development, but I am a newbie in PHP, so I still want to Use PHPStrom (I just bought it a year ago, so there is no need to waste it, and the integrated development environment may be helpful for development).
The above is the background.
I would like to know what method PHP masters use to develop PHP under Mac, and what method is recommended for novices. If you set up the environment locally on Mac, transplant it to the server and need to reconfigure it, etc. It will be a hassle. There won't be too many differences and problems.
Also, does PHPStorm support remote editing of projects on the server? I know that TextMate and the like have related command line plug-ins. You can open remote files via SSH and bind them remotely after editing, but I don’t want to use tools like TextMate or Sublime this time

I hope everyone who sees the problem or seniors can discuss it with me and help me. I will always refresh the comments online.

-------Update---------

There is such a big difference in everyone’s answers

------Update again---------

In the end, my decision was consistent with the accepted answer, thank you all friends.

In addition, what I want to ask is, what's wrong with this question? Is there something wrong with being downvoted by -1?

Reply content:

As the title says, I want to do PHP development under mac. I want to see the real-time effect locally, and then deploy it to the server (CentOS) after development, or use SSH to directly connect to the server VIM for development, but I am a newbie in PHP, so I still want to Use PHPStrom (I just bought it a year ago, so there is no need to waste it, and the integrated development environment may be helpful for development).
The above is the background.
I would like to know what method PHP masters use to develop PHP under Mac, and what method is recommended for novices. If you set up the environment locally on Mac, transplant it to the server and need to reconfigure it, etc. It will be a hassle. There won't be too many differences and problems.
Also, does PHPStorm support remote editing of projects on the server? I know that TextMate and the like have related command line plug-ins. You can open remote files via ssh and bind them remotely after editing, but I don’t want to use tools like TextMate or Sublime this time

I hope everyone who sees the problem or seniors can discuss it with me and help me. I will always refresh the comments online.

-------Update---------

There is such a big difference in everyone’s answers

------Update again---------

In the end, my decision was consistent with the accepted answer, thank you all friends.

In addition, what I want to ask is, what's wrong with this question? Is there something wrong with being downvoted by -1?

As a newbie, you can consider my ideas. Use MAC for local development. Do not use vagrant, docker, or virtual machines. The reason is very simple. In the initial learning stage, the MAC environment is not much different from the server environment. The introduction of Docker and Vagrant will only affect the learning of PHP. It is better to focus on the real work than to spend time messing around with those things. There is no need to deploy the project to the server after development. As long as it can run under your MAC. RememberThe advantage of MAC development is that it is similar to the server environment, you are not using windows...

Install the development environment directly on mac

PHPStrom supports ftps synchronization code to the server, and can be set to automatically synchronize when pressing save

Or you can use samba or rsync
Mac’s server environment is similar to Linux

Are they all Unix? Just use it

No one recommends Vagrant, I’m not convinced

CentOS 7.0 + Docker

Two laptops.

Mac: mainly used to assist development
Ubuntu: main development machine

As for the development environment and server environment, I personally feel that if the code problem is not big, you will not encounter many problems when going online. Moreover, the two machines are great when developing some modules, such as WeChat and DingTalk.

What the poster said Using SSH to directly connect to the server for VIM development is not feasible in our company.

MAMP FREE VERSION

I directly set the SB editor as the default editor of sftp, edit directly, and directly throw a file manager into it for online web editing.

Win users come here and get the answer:
Linux virtual machine or independent Linux server.

Personally, I would never create a running environment on the local machine. There are too many uncertainties (Mac is okay, but Win is really bad). It is best for the running environment to be the same as the final production environment, with fewer problems.

PHPStorm and all editors have code synchronization functions, and even if they don’t, there is third-party code synchronization.

Your question: Is it troublesome to build the environment locally, migrate it to the server and need to reconfigure it, etc.? Will there be too many differences... This depends on the dependence of your project on the running environment. . For example, my own project A has almost no dependencies and can be used just by copying it; but project B needs to write files to the server (the absolute path in Linux is different from Win) and read the database (you need to install Mysql and redis on Win). You even have to run an exec shell script (Win is out of the question).

I don’t use a Mac, but it is recommended to set up an environment, or directly use one-click installation package (inherit the development environment). A virtual machine is not necessary

<code>IF ENV=Dev 
    Vagrant
    
    
IF ENV=Product
    Docker     </code>
Copy after login

Thanks for the invitation.

Local development:

<code>XAMPP
</code>
Copy after login

IDE:

<code>PHPStorm
</code>
Copy after login

There must be a deviation between the server environment and the local environment, and you need to deal with it yourself.

But in recent years, there has been a very cool thing called Docker

<code>一个服务器环境的虚拟机,现在和将来都会是主流。</code>
Copy after login

Our company uses VirtualBox+vagrant

Nginx+php-fpm built locally. I used vagrant before, but the speed was a bit slow. Comparing various aspects, I think it is better to build the native one locally.

If you are a newbie, you don’t need to think so much. First, set it up locally and fiddle around for a while. If you encounter many problems and the system jumps a few times, you will get Docker:)

Recommend Vagrant: the configuration is simple, if you are not familiar with Linux, it will be enough for you, and you can restore it at any time if the configuration is broken. If you don’t want to mess around, there are many ready-made environment packages that others have prepared. You can download them and use them directly. This way you can spend more time learning PHP knowledge instead of messing with the environment. In addition, unless you are very familiar with Vim, otherwise Don't assume that it can bring you the same work efficiency as phpstorm. It's okay to write a helloworld, but forget it if you're working on a project.

Recommend Vagrant

Cultivate the collaboration ability of DevOps development and operation and maintenance,
Ubuntu Desktop + Ubuntu Server is the best and most productive combination.
I use Ubuntu desktop to develop PHP, the editor is Geany, and the IDE occasionally uses Netbeans.
Among them, Netbeans Supports remote sftp project development, that is, the project is built on the development machine, but the running environment is a remote Linux server.
If you use a Mac, you can use VirtualBox to virtualize a CentOS to run it, but it is not recommended because virtualization takes up a lot of resources and has poor performance. In case of loss, it is better to build a PHP environment locally on Mac.

Use brew to directly install the required components, which is very flexible, but using a virtual machine is slower. I also wrote an article saying that it is not recommended for people using Unix-like systems to use virtual machines for web development.

macOS+vagrant

Why use a virtual machine when you have a Mac? UNIX itself is not much different from Linux in terms of instructions

No need, I use xampp, but I do the front-end. . Just concentrate on writing code and understand a little bit about the server environment

You can try Docker virtual containers. Now the official Docker image is available in China, and the partner is Alibaba Cloud

There is an integrated environment for beginners: xampp
Learn more: build your own environment

I also develop on Mac, but I am not a professional PHP developer. I just wrote a few projects. Using Mamp to build an environment is very, very easy to use. One-click basic settings and subsequent configuration modifications are also very convenient. It is recommended for novices to use this.
The software developed is zendStudio, which is quite comfortable to use and has complete functions. It's just that this software is not free. I used the cracked version when I was a student party.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template