Useful Homebrew Apache-PHP Commands

Written by: admin | Date: Tuesday, June 1st, 2021
Categories: PHPReference

First off… Homebrew and Apache on the Mac OS are SEPARATE from the default Mac OS Apache installation. You can edit files and change configs in terminal until you’re blue in the face, and see no changes. That’s because you’re probably installing or editing one, while checking the version or functionality of the other.

Homebrew Terminal Commands
Command list here: https://docs.brew.sh/Manpage

Install apache:
bin brew install httpd
Start apache (httpd):
brew services start httpd

More HTTPD commands:

brew services stop httpd

brew services restart httpd

Set PHP version
Uncomment and add this to your httpd.conf:
LoadModule php7_module /usr/local/opt/php@7.4/lib/httpd/modules/libphp7.so
Above example is obviously for PHP7.4

Apache error logs:
/usr/local/var/log/httpd/error_log

/usr/local/var/log/httpd/access_log


PHP illegal string offset warning

Written by: admin | Date: Tuesday, March 29th, 2016
Categories: JoomlaPHPReference

Ran across the PHP Joomla warning after upgrading one of my apps to Joomla 3.45:

Warning: Illegal string offset 'name' in

function golfLeagueShowFormats($formatObject){

$delimiter = ",";
$format_array = explode($delimiter, $formatObject);
foreach ($format_array as $format) {
$formatnumber = $format['name'];
golfLeagueGetFormatName($formatnumber);
//return 'poop';
}
}

It’s just a warning that only shows up in developer mode. Disabling developer mode would get rid of the warning but I decided to figure this out to make sure all the code was clean. Here’s the solution, to change $format[‘name’] to $format[0]


// convert format array to individual objects part 1
function golfLeagueShowFormats($formatObject){

$delimiter = ",";
$format_array = explode($delimiter, $formatObject);
foreach ($format_array as $format) {
$formatnumber = $format[0];
golfLeagueGetFormatName($formatnumber);
}
}