Skip to content

Instantly share code, notes, and snippets.

@debojyoti452
Last active September 20, 2023 19:04
Show Gist options
  • Save debojyoti452/858a115c58b738349d33317abf630f65 to your computer and use it in GitHub Desktop.
Save debojyoti452/858a115c58b738349d33317abf630f65 to your computer and use it in GitHub Desktop.
Php developement Env setup in Mac OS

Setting up the specified environment on a Mac can be broken down into several steps. Below are the steps to help you set up the requirements on a macOS system:

  1. Install Homebrew (if not already installed):

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. Install PHP 7.4 and extensions:

    brew install php@7.4

    Once installed, you can install the extensions:

    brew install php@7.4-imagick php@7.4-soap

    (The other extensions mentioned, such as xml, json, zip, iconv, gd, fileinfo, openssl, and simplexml are usually bundled with the core PHP distribution. So you won't need to install them separately.)

  3. Change PHP settings:

    To update the max_input_vars, you'll have to modify the php.ini file. Find its location:

    php --ini

    Open the provided php.ini location with a text editor, e.g.,

    nano /usr/local/etc/php/7.4/php.ini

    Search for max_input_vars and change its value to 5000. If the line doesn't exist, add it:

    max_input_vars = 5000
    

    Save the changes and exit the editor.

  4. Install MySQL:

    For simplicity, I'm demonstrating with MariaDB, but the process would be similar for other distributions:

    brew install mariadb

    Start the MariaDB service:

    brew services start mariadb
  5. Install Node and Yarn:

    brew install node
    brew install yarn
  6. Install Bower:

    Since Bower is installed via npm (which comes with Node):

    npm install -g bower
  7. Install Composer:

    It's mentioned that there were problems with Composer v2+ on Windows. However, on Mac, the latest version of Composer should be fine. If you do encounter issues, you can specifically install version 1.10:

    brew install composer

    To install a specific version:

    composer self-update 1.10

    (Note: If in the future, you decide to revert to the latest version, just run composer self-update.)

  8. Ensure your PATH is set correctly:

    To use these tools easily from the command line, you'll want to ensure they're available in your PATH. For instance, if you installed PHP through Homebrew, add this to your ~/.zshrc or ~/.bash_profile (depending on your shell):

    export PATH="/usr/local/opt/php@7.4/bin:$PATH"
    export PATH="/usr/local/opt/php@7.4/sbin:$PATH"

    Then, load the changes:

    source ~/.zshrc

    Or, if you use bash:

    source ~/.bash_profile
  9. Restart services:

    If you made changes to PHP settings or installed services, ensure you restart them to have the new configurations take effect.

  10. Check installations:

    It's a good idea to check if everything is correctly installed:

    php -v
    mysql --version
    node -v
    yarn -v
    bower --version
    composer --version

That should get you up and running with the specified requirements on your Mac. If you encounter any issues during the setup process, always refer to the official documentation or community forums for troubleshooting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment