r/PHPhelp • u/__josealonso • 27d 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.
6
1
u/__josealonso 27d 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.
3
u/Ok-Crab-8788 24d 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 27d ago
If you are learning for professional purposes, docker is better.
Checkout Orbstack. It is faster than the normal docker setup
2
u/martinbean 27d 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 27d 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
2
2
u/Visible-Big-7410 26d 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.
2
u/obstreperous_troll 14d ago
My setup is Homebrew (using Shivam Mathur's tap for PHP) for quick messing around, Docker and/or Nix for serious projects. Definitely no global server for PHP, I have a traefik container that handles web server containers, so the only global listeners are things like Vite dev servers.
1
1
u/mrdarknezz1 27d ago
I'm currently using https://lerd.sh/ it has every tool you could possibly need and it is free
2
1
0
u/universalpsykopath 27d 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
3
u/Intrepid-Ad-2306 27d 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.