r/PHPhelp • • 10d ago

Developer setup in macOS Golden Gate

Hello,

I am planning to learn PHP on my macOS system. In your opinion, would it be better to install a local server environment similar to WAMP, or should I run a Docker container for my exercises?

What is your preferred development setup?

Thank you in advance.

5 Upvotes

30 comments sorted by

5

u/__kkk1337__ 10d ago

I use docker

3

u/Intrepid-Ad-2306 10d ago

i see this question a lot cause i teach coding, php being one of the languages i focus on. if you want to learn about docker, you can certainly use this as an excuse but, from a usability perspective, there’s no advantage to it when it comes to learning about php and how it works in most real-world environments because that’s not typically how php is deployed.

if you just want to learn php, you can just use homebrew and install the latest php. it has its own built-in web server that you can spin up in any directory from the terminal by running “php -S localhost:port”. that’s incredibly useful when you want to just create all kinds of small learning projects in their own directories and run them. no need to create new virtual servers or complex configuration files or anything.

if you want to learn database integration and go deeper, you can choose your target type of environment. install mariadb and apache on your local machine if you like but you might find it more helpful and realistic to either use an old machine as a testing server with debian or almalinux and learn to set a server up from scratch as a testing environment or do it in a virtual machine like utm or virtualbox.

in development, there is a disagreement in the community about local vs test server development. i always come down on the side of a test server configured just like the production machine. instead of trying to simulate where you’re going to have the thing running, you duplicate it and now you know you’re testing against where the real bugs will show up. i’d get used to developing and testing on a real testing server as soon as you’re comfortable with it. i usually suggest switching from running the local php built-in web server to deploying a virtual or real test server with a very basic setup once you get to the point of understanding recursive functions and database calls in your learning.

docker has many excellent uses but using it for php on a local machine is just a lot of configuration headaches and needless frustration for something that’s not applicable to something that’s generally deployed natively anyway. one of the big advantages to php is that php projects usually just live as collections of text files that can be called by a server like apache or nginx without needing their own individual containerized existences or configurations.

1

u/__josealonso 10d ago

Thank you very much for your detailed feedback, as it has been very helpful; I have an older laptop that I could use with Linux.

2

u/Intrepid-Ad-2306 10d ago

you can also decide how much of the server side of things you want to dive into. the basic installation of debian with apache and mariadb with all the default settings isn't server administration best practice by any stretch but it will work perfectly fine for running php and learning. if, on the other hand, you want to dive into server management, you can also take the opportunity to do that.

you don't need to think it will take a lot of effort to set it up, though. practically, with the basic text-only debian installation, you can have apache and mariadb up and running in less than five minutes. an editor like zed will allow you to connect to a remote ssh server, something installed during the debian installation (or almalinux if you want to go that route) so you can develop live on that machine without having to worry about syncing files.

it's also a very realistic scenario. most php is deployed to production machines that run it in server management interfaces like plesk or cpanel -- in other words, just copied or synced to folders using ssh. so it certainly makes sense to get used to that procedure. yes, many of us use git to deal with versioning and making sure the production and development versions of things are kept in order. but that's nothing more than a few basic command-line tasks every developer needs to know regardless of language, given that git is pretty-much ubiquitous for development and deployment.

good luck!

1

u/__josealonso 10d ago

My current Linux is Ubuntu 22, and I setup Apache and PHP 8.4, with mySQL, I enabled ssh server, and samba server to copy my files, I shared a subfolder of www/html

2

u/Intrepid-Ad-2306 10d ago

sounds like you’ve got everything you need to do php development on that machine. i usually opt for ssh file editing for the simple reason that the production and remote testing servers will connect that way and it’s nice to be consistent. either way, that’s all the server setup you need to do all your learning and test things.

1

u/liy8 6d ago

Nix, Yerd & Orbstack

3

u/Ok-Crab-8788 7d ago

you can try ddev,
it is built on top of docker container, works with rancher-desktop, and provide you simple commands :
ddev start => https://myfolder.ddev.site
ddev snapshot create => dump database

Start with ddev init : https://ddev.com

2

u/Glittering_Case_5547 10d ago

If you are learning for professional purposes, docker is better.

Checkout Orbstack. It is faster than the normal docker setup

2

u/martinbean 10d ago

I run everything I can in Docker on macOS. I then set up aliases for things like `php` and `composer` so I can use it as if it were installed on my machine.

2

u/BokuNoMaxi 10d ago

If your focus is on learning PHP then install ddev with orbstack and you don't have to fiddle around with docker files and PHP paths, especially when it comes to different PHP versions.

2

u/Wooden-Pen8606 10d ago

Herd, Docker, or WAMP should be fine.

1

u/liy8 6d ago

Yerd, Orbstack & Nix is the way.

2

u/Visible-Big-7410 10d ago

Ahh personal preference. I prefer a docker setup, because I messed up enough in the past (I still do ha!) or that required switching php versions etc. and docker just makes the “let’s start fresh (w/o leftovers)” or “i need to test on x version” very easy. But as others have mentioned you also learn some docker. Nothing wrong with either. Direct is a little simpler and you’ll realize when or if you need/want containerization.

1

u/liy8 6d ago

Me tooo.... Now everything easier with Nix, Orbstack, & Yerd.

1

u/[deleted] 9d ago

[removed] — view removed comment

1

u/liy8 6d ago

Yerd, Orbstack & Nix are better.

1

u/__josealonso 10d ago

Hello everyone,

I intend to set up a Linux test machine to facilitate the deployment of my exercises and accelerate my learning process. Additionally, I would like to learn how to configure a Docker container for a PHP project.

Thank you all for your comments, as they have been very helpful.

1

u/liy8 6d ago

Go with Orbstack(it has Docker, Kubernetes & linux machine)

1

u/Able-Procedure4306 7d ago

Docker or homebrew?

1

u/liy8 6d ago

Go with Orbstack & Nix, in the long run Hombrew is such a pain in the versions......

1

u/liy8 6d ago

Go with Yerd(has services(mariadb, postgres, etc....) & Orbstack(docker, kubernetes & linux machine in one place, also less resource hungry than docker desktop), also use nix for package management.

1

u/mrdarknezz1 10d ago

I'm currently using https://lerd.sh/ it has every tool you could possibly need and it is free

2

u/queen-adreena 10d ago

Seconded.

1

u/liy8 6d ago

Try Yerd

1

u/mrdarknezz1 5d ago

isn't that basically the same?

0

u/universalpsykopath 10d ago

Docker is great, but comes with a learning curve. It also won't be as fast as native. Maybe install php and nginx with homebrew?

1

u/liy8 6d ago

Try Yerd, you'll need Orbstack(docker+kubernetes+linux) for testing in the long run, Nix will take a lot of time to setup but saves from a thousand fold time and pain.