I have been wanting to get more confident in my coding for some time. Even though I'm working on custom Drupal modules all the time, writing scripts and hook updates, I still feel out of my depth when initially encountering new code. In fact, the other day, I was reading through a yml-based migration configuration and even at that got tripped up. Let alone looking at the plugin, itself. So I started looking at some good books on PHP 8 and came across The Art of Modern PHP 8 by Joseph Edmonds.
My intention is to follow this book and get through it as a way to becoming more adept at PHP 8.
First step, though, is getting php running.
I didn't know for sure if my MacBook Pro (M2, 2022, 13 in), running macOS Ventura 13.4 had PHP installed already, so I typed in Terminal
and got the following
zsh: command not found: php
No problem. I had Hombrew installed already, so I ran
brew install php
And then got screen upon screen of installs, ending with
To enable PHP in Apache add the following to httpd.conf and restart Apache: LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/libphp.so <FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch> Finally, check DirectoryIndex includes index.php DirectoryIndex index.php index.html The php.ini and php-fpm.ini file can be found in: /opt/homebrew/etc/php/8.3/ To start php now and restart at login: brew services start php Or, if you don't want/need a background service you can just run: /opt/homebrew/opt/php/sbin/php-fpm --nodaemonize
First things, first, though, in terms of getting a handle on PHP: RTFM, as my friend Harry says.
Looking at the PHP documentation on Classes and Objects is going to take a while, though, as the first section, "The Basics" is 20 pages.