bomonike

What a Pretty Hypertext Preprocessor (PHP)!

US (English)   Norsk (Norwegian)   Español (Spanish)   Français (French)   Deutsch (German)   Italiano   Português   Estonian   اَلْعَرَبِيَّةُ (Egypt Arabic)   Napali   中文 (简体) Chinese (Simplified)   日本語 Japanese   한국어 Korean

Overview

Community

  1. The marketing landing page for the PHP language is:

    https://www.php.net

    renowned voices in the PHP community, including Larry Garfield, Fabien Potencier, Nils Adermann, Elizabeth Barron,

  2. Documentation

    https://www.php.net/manual/en/

Certifications

“Zend PHP Certified Engineer” is a well-known vendor-specific exam for PHP developers. For $200 for testing or $1295 with a class to Perforce,

“PHP Developer Fundamentals” exam from IC3 (administered by Pearson) is the entry-level PHP exam. Answer 70% of 40 questions over 50 minutes online Certiport Console 8. The IC PHP covers nine domains of knowledge and skill:

  1. Development Environment: Web server and database MySQL/MariaDB PhPMyAdmin
  2. PHP Fundamentals: General notions Style programming Limitation structure of the data Manage the output of PHP script
  3. Conditional instruction of control and cycles: Repetitive operations
  4. Complex data structures: Arrays
  5. PHP code management: Re-use the PHP code Functions for the variables management The functions for the management, comparison and string formatting The functions for the management of the complex structures of data The functions for the management of the dates Customized functions Send email in PHP
  6. Data recovery and check in an HTML form
  7. Maintain information in PHP: Sessions
  8. The DBMS MySQL and MariaDB
  9. Interaction with I DBMS MySQL and MariaDB

To add generative AI to PHP programs, you can use LLPhant, a comprehensive PHP Generative AI Framework using OpenAI GPT 4 Inspired by Langchain. Install it using command “composer require theodo-group/llphant”.

https://www.youtube.com/watch?v=lTr06V9uyts

PHP Version and Location

If it’s installed, the version of PHP is obtained from this Terminal command:

php -v

If you get a response, see the Install section below.y

A Pretty Hypertext Preprocessor (PHP) was included by Apple on OS X (before MacOS):

On Mojave, the response was:

PHP 7.1.23 (cli) (built: Feb 22 2019 22:19:32) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

On Sierra, the response was:

PHP 5.6.28 (cli) (built: Dec  6 2016 12:38:54) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

On Yosemite, the response was:

PHP 5.5.14 (cli) (built: Sep  9 2014 19:09:25)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies

For the location of the PHP being used by the command line:

which php

On my Yosemite, the response is:

/usr/bin/php

Install PHP on macOS

  1. Install using Homebrew:

    yes brew install php
    
  2. Get version:
    php -v
    

    For example:

    PHP 8.5.7 (cli) (built: Jun  2 2026 20:59:56) (NTS)
    Copyright (c) The PHP Group
    Built by Homebrew
    Zend Engine v4.5.7, Copyright (c) Zend Technologies
       with Zend OPcache v8.5.7, Copyright (c), by Zend Technologies
    
  3. The history of PHP releases are at:

    https://github.com/php/php-src/releases

  4. Scroll down to the latest (largest) version for “OS X” and click “Download” of the macOS installer (.dmg), not a VM image from:

    https://www.apachefriends.org/download.html

    The most popular PHP development environment is XAMPP, an acronym of components:

    • Apache
    • MariaDB
    • PHP
    • Perl

    XAMPP is Windows-focused.

    WARNING: Don’s use XAMPP to develop Nextcloud which officially doesn’t support Windows. You’ll fight with PHP extensions (gd, mysqli, mbstring), mod_rewrite, and permissions.

    1. Click “Downloads” folder, then “Save” in the pop-up to store file such as “xampp-osx-8.2.4-0-installer.dmg”.
    2. Click the downloads icon in your browser and click the file you just downloaded.
    3. Double-click the “installer.app” file
    4. Let the pop-up.
    5. Click the Apple icon at the upper-left corner to open System Settings app.
    6. Click “Privacy & Security” in the menu.
    7. Scroll to the Security section. Next to the message that XAMPP was blocked, click “Open Anyway”. Again.
    8. Click Open Anyway and enter your password.
    9. The Setup app should pop up. In the XAMPP Setup Wizard, click “Next” repeatedly.
    10. Quit the installer app.

    Start

  5. Start manager-osx.app (Application Manager) in ~/Applications/XAMPP From the CLI,
    open -a manager-osx.app
    
  6. Click “Open Application Folder” xampfiles in a new Finder window.
  7. Click “Managed Servers”, select “MySQL database” and click Start. Select “Apache Web Server” and click Start.
  8. Click “Configure”. Notice the port defaults to 3306.

  9. Verify it works: Open a browser and go to: http://localhost:3306

    You should see the XAMPP dashboard.

  10. Start using CLI command (requires password entry):
    sudo /Applications/XAMPP/xamppfiles/xampp start && sleep 2 && echo "================ STATUS ================" && sudo /Applications/XAMPP/xamppfiles/xampp status
    

    or individually:

    sudo /Applications/XAMPP/xamppfiles/xampp startapache
    sudo /Applications/XAMPP/xamppfiles/xampp startmysql
    
  11. CLI to check whether services are running:
    curl -sSI http://localhost/ | head -n 1     # Apache: expect "HTTP/1.1 200 OK" (or 3xx)
    nc -z -v localhost 3306                      # MySQL/MariaDB: "succeeded" = port open
    nc -z -v localhost 21                        # ProFTPD: FTP port
    
  12. Install Visual Studio Code

  13. Click “Configure”, then “Open Config file”. OK.
  14. Can copy file to /etc/my.cnf to set global options.
  15. ~/.my.cnf to set user-specific options.
  16. from /Applications/XAMPP/xamppfiles/var/mysql) mysql-data-dir/my.cnf to set server-specific options

  17. Sample program: Convert Celsius to Fareinheit temperature.
    $c = ($f - 32) * (5 / 9);
    echo $c from $f
    

PHP language basics:

  1. Video courses on PHP by Coursera: https://www.coursera.org/search?query=php

    • Intro to PHP” LAMP stack using MariaDB

Activate PHP for Apache

To activate PHP using the Pico text editor that comes with Macs:

sudo pico /etc/apache2/httpd.conf

Within pico, press Ctrl+W and type php to search for the php5_module statement.

Press cursor key left to the right of the # comment character, press the backspace key to delete it. PHP is activated after you press Ctrl+X and Ctrl+Y to confirm Yes.

Alternately, to activate PHP using the vi text editor that also comes with Macs:

sudo vi /etc/apache2/httpd.conf

To find php…

Press ‘x’ over the ‘#’ character to delete it.

Type ‘:w!’ to save. Type ‘ZZ’ (upper case) to quit.

Only for Yosemite, also uncomment line 166:

LoadModule userdir_module libexec/apache2/mod_userdir.so

And also line 493:

#Include /private/etc/apache2/extra/httpd-userdir.conf

Activate php.ini

To activate PHP using the pico text editor that comes with Macs:

cd /private/etc

Copy the default file to a .ini file:

sudo cp php.ini.default php.ini

Enable Apache

For Yosemite only, open the file with:

sudo vi /etc/apache2/extra/httpd-userdir.conf

Uncomment line 16:

#Include /private/etc/apache2/users/*.conf

Save and exit.

Specify Mac User Name in Apache

Ensure that your user name is listed within:

ls -la /etc/apache2/users

In addition to the Guest.conf listed, there should be a .conf file with your Mac user name (mine is wilsonmar).

Such file may not be created while upgrading to Mountain Lion. Contents of this file is different on Yosemite:

<Directory "/Users/wilsonmar/Sites/">
AddLanguage en .en
LanguagePriority en fr de
ForceLanguagePriority Fallback
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from localhost
Require all granted
</Directory>

Establish Sites folder PHP website default file

By popular convention, the Sites folder (with a capital S) is used to store website files. Create one under the default /Applications folder from the command line:

mkdir ~/Sites

Create a HTML file to display by default when no file is specified:

echo “&LT;html>&LT;body>&LT;h1>My site works&LT;/h1>&LT;/body>&LT;/html>” > ~/Sites/index.html.en

/Library/WebServer/Documents/index.html.en . This contains the text “It works!”

Launch Apache

Older versions of Apache had a UI in System Preferences > Sharing and enable Web Sharing. But on Yosemite:

Within a Terminal:

sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist

Check the version of Apache installed:

httpd -v

The response on my Yosemite is:

Server version: Apache/2.4.9 (Unix)

Server built: Sep 9 2014 14:48:20</tt>

See http://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-10-yosemite/

Libmcrypt PHP

http://coolestguidesontheplanet.com/install-mcrypt-php-mac-osx-10-10-yosemite-development-server/

To add modules to PHP, add libmcrypt-2.5.8 and PHP source code from http://us.php.net/get/php-5.5.14.tar.gz/from/a/mirror using these instructions: http://michaelgracie.com/2011/07/21/plugging-mcrypt-into-php-on-mac-os-x-lion-10-7/

Courses at Coursera.com

Building Web Applications in PHP from University of Michigan Best for: intermediate learners, students with months to commit, and those aiming to build full web applications with User Interfaces formatted using CSS.

Full-Stack Web Development: PHP, HTML, CSS & JavaScript from Board Infinity Best for: beginners interested in full-stack development, learners with a few months available, and those wanting a specialization credential

Building Database Applications in PHP from University of Michigan Best for: intermediate developers, learners focused on database skills, and those ready to enhance PHP with MySQL integration

Introduction to VueJS Framework from Codio Best for: beginners with 1-4 weeks availability, learners new to Vue.js, and those seeking foundational web development skills

The Complete Vue.js Course for Beginners from Packt Best for: beginners with 1-3 months to learn, those interested in JavaScript frameworks, and learners preferring comprehensive beginner courses

Vue.js 3 for Beginners: Build Modern Web Applications from Packt Best for: intermediate learners with 3-6 months commitment, developers focusing on modern web apps, and those wanting to master Vue.js 3 features

Fundamentals of VueJS from Board Infinity Best for: intermediate learners with short-term availability, web developers interested in JavaScript frameworks, and those aiming to strengthen Vue.js fundamentals

More on OSX

This is one of a series on Mac OSX:


26-06-13 v003 new from wilsonmar @macos-php.md created 2014-08-09