Skip to content

Instantly share code, notes, and snippets.

@codeadamca
Last active May 8, 2024 22:54
Show Gist options
  • Save codeadamca/09efb674f54172cbee887f04f700fe7c to your computer and use it in GitHub Desktop.
Save codeadamca/09efb674f54172cbee887f04f700fe7c to your computer and use it in GitHub Desktop.
How to add new PHP versions to MAMP on a Mac

Adding Versions of PHP to MAMP on a Mac

If you're working on a project that requires a version of PHP higher than the versions that MAMP comes with, you can easily add additional verions.

My version of MAMP came installed with PHP 7.4.21 and 8.0.8. I'm attempting to use MAMP to host a Laravel application which requires at least PHP 8.1.

The version of PHP MAMP uses is often different than the version you have installed. I have installed PHP using Brew. I'm currently running PHP 8.1.8. If you want to check your installed version of PHP, use the terminal and run the following command:

php --version

terminal-php-version

  1. First we need to copy the installed PHP files to MAMP. Using Finder, navigate to /usr/local/Cellar/php and you should find a folder named after the installed version of PHP. For me it was 8.1.8. Copy this folder.

  2. Navigate to the folder that MAMP stores PHP versions. For me this was /Applications/MAMP/bin/php. Paste this folder here.

  3. Rename this folder to php8.1.8 (use your PHP version number).

  4. Next we need the PHP modile file. Navigate to /usr/local/lib/httpd and copy the modules folder. Inside this folder is the PHP module file names libphp.so.

  5. Navigate to /Applications/MAMP/bin/php/php8.1.8 and paste the modules folder.

  6. Close and restart MAMP.

  7. Choose PHP 8.1.8 from the frop down and you should be good to go!

mamp-php-8 1 8

I have a video walk-through on YouTube!

@marcoandrei
Copy link

Hello, PHP friends!

As I'm using High Sierra, I used MacPorts to install PHP 8.3 and avoid some problems that occurs when using Brew in old macOS versions.

PHP 8.3 is correctly installed, but it appears that everything is spreaded at /opt/local folder:

$ port contents php83 @8.3.6_0+libedit 
Port php83 contains:
  /opt/local/bin/php-config83
  /opt/local/bin/php83
  /opt/local/bin/phpize83
  /opt/local/etc/php83/php.ini-development
  /opt/local/etc/php83/php.ini-production
  /opt/local/etc/select/php/php83
  /opt/local/include/php83/php/TSRM/TSRM.h
  /opt/local/include/php83/php/TSRM/tsrm_win32.h
  /opt/local/include/php83/php/Zend/Optimizer/zend_call_graph.h
  /opt/local/include/php83/php/Zend/Optimizer/zend_cfg.h
  /opt/local/include/php83/php/Zend/Optimizer/zend_dfg.h
  /opt/local/include/php83/php/Zend/Optimizer/zend_dump.h
  /opt/local/include/php83/php/Zend/Optimizer/zend_func_info.h
  /opt/local/include/php83/php/Zend/Optimizer/zend_inference.h
  /opt/local/include/php83/php/Zend/Optimizer/zend_optimizer.h
  /opt/local/include/php83/php/Zend/Optimizer/zend_ssa.h
  /opt/local/include/php83/php/Zend/zend.h
  /opt/local/include/php83/php/Zend/zend_API.h
  /opt/local/include/php83/php/Zend/zend_alloc.h
  /opt/local/include/php83/php/Zend/zend_alloc_sizes.h
  /opt/local/include/php83/php/Zend/zend_arena.h
  /opt/local/include/php83/php/Zend/zend_ast.h
  /opt/local/include/php83/php/Zend/zend_atomic.h
  /opt/local/include/php83/php/Zend/zend_attributes.h
  /opt/local/include/php83/php/Zend/zend_attributes_arginfo.h
  /opt/local/include/php83/php/Zend/zend_bitset.h
  /opt/local/include/php83/php/Zend/zend_build.h
  /opt/local/include/php83/php/Zend/zend_builtin_functions.h
  /opt/local/include/php83/php/Zend/zend_builtin_functions_arginfo.h
  /opt/local/include/php83/php/Zend/zend_call_stack.h
  /opt/local/include/php83/php/Zend/zend_closures.h
  /opt/local/include/php83/php/Zend/zend_closures_arginfo.h
  /opt/local/include/php83/php/Zend/zend_compile.h
  /opt/local/include/php83/php/Zend/zend_config.h
  /opt/local/include/php83/php/Zend/zend_config.w32.h
  /opt/local/include/php83/php/Zend/zend_constants.h
  /opt/local/include/php83/php/Zend/zend_constants_arginfo.h
  /opt/local/include/php83/php/Zend/zend_cpuinfo.h
  /opt/local/include/php83/php/Zend/zend_dtrace.h
  /opt/local/include/php83/php/Zend/zend_enum.h
  /opt/local/include/php83/php/Zend/zend_enum_arginfo.h
  /opt/local/include/php83/php/Zend/zend_errors.h
  /opt/local/include/php83/php/Zend/zend_exceptions.h
  /opt/local/include/php83/php/Zend/zend_exceptions_arginfo.h
  /opt/local/include/php83/php/Zend/zend_execute.h
  /opt/local/include/php83/php/Zend/zend_extensions.h
  /opt/local/include/php83/php/Zend/zend_fibers.h
  /opt/local/include/php83/php/Zend/zend_fibers_arginfo.h
  /opt/local/include/php83/php/Zend/zend_float.h
  /opt/local/include/php83/php/Zend/zend_gc.h
  /opt/local/include/php83/php/Zend/zend_gdb.h
  /opt/local/include/php83/php/Zend/zend_generators.h
  /opt/local/include/php83/php/Zend/zend_generators_arginfo.h
  /opt/local/include/php83/php/Zend/zend_globals.h
  /opt/local/include/php83/php/Zend/zend_globals_macros.h
  /opt/local/include/php83/php/Zend/zend_hash.h
  /opt/local/include/php83/php/Zend/zend_highlight.h
  /opt/local/include/php83/php/Zend/zend_hrtime.h
  /opt/local/include/php83/php/Zend/zend_inheritance.h
  /opt/local/include/php83/php/Zend/zend_ini.h
  /opt/local/include/php83/php/Zend/zend_ini_parser.h
  /opt/local/include/php83/php/Zend/zend_ini_scanner.h
  /opt/local/include/php83/php/Zend/zend_ini_scanner_defs.h
  /opt/local/include/php83/php/Zend/zend_interfaces.h
  /opt/local/include/php83/php/Zend/zend_interfaces_arginfo.h
  /opt/local/include/php83/php/Zend/zend_istdiostream.h
  /opt/local/include/php83/php/Zend/zend_iterators.h
  /opt/local/include/php83/php/Zend/zend_language_parser.h
  /opt/local/include/php83/php/Zend/zend_language_scanner.h
  /opt/local/include/php83/php/Zend/zend_language_scanner_defs.h
  /opt/local/include/php83/php/Zend/zend_list.h
  /opt/local/include/php83/php/Zend/zend_llist.h
  /opt/local/include/php83/php/Zend/zend_long.h
  /opt/local/include/php83/php/Zend/zend_map_ptr.h
  /opt/local/include/php83/php/Zend/zend_max_execution_timer.h
  /opt/local/include/php83/php/Zend/zend_mmap.h
  /opt/local/include/php83/php/Zend/zend_modules.h
  /opt/local/include/php83/php/Zend/zend_multibyte.h
  /opt/local/include/php83/php/Zend/zend_multiply.h
  /opt/local/include/php83/php/Zend/zend_object_handlers.h
  /opt/local/include/php83/php/Zend/zend_objects.h
  /opt/local/include/php83/php/Zend/zend_objects_API.h
  /opt/local/include/php83/php/Zend/zend_observer.h
  /opt/local/include/php83/php/Zend/zend_operators.h
  /opt/local/include/php83/php/Zend/zend_portability.h
  /opt/local/include/php83/php/Zend/zend_ptr_stack.h
  /opt/local/include/php83/php/Zend/zend_range_check.h
  /opt/local/include/php83/php/Zend/zend_signal.h
  /opt/local/include/php83/php/Zend/zend_smart_str.h
  /opt/local/include/php83/php/Zend/zend_smart_str_public.h
  /opt/local/include/php83/php/Zend/zend_smart_string.h
  /opt/local/include/php83/php/Zend/zend_smart_string_public.h
  /opt/local/include/php83/php/Zend/zend_sort.h
  /opt/local/include/php83/php/Zend/zend_stack.h
  /opt/local/include/php83/php/Zend/zend_stream.h
  /opt/local/include/php83/php/Zend/zend_string.h
  /opt/local/include/php83/php/Zend/zend_strtod.h
  /opt/local/include/php83/php/Zend/zend_strtod_int.h
  /opt/local/include/php83/php/Zend/zend_system_id.h
  /opt/local/include/php83/php/Zend/zend_type_info.h
  /opt/local/include/php83/php/Zend/zend_types.h
  /opt/local/include/php83/php/Zend/zend_variables.h
  /opt/local/include/php83/php/Zend/zend_virtual_cwd.h
  /opt/local/include/php83/php/Zend/zend_vm.h
  /opt/local/include/php83/php/Zend/zend_vm_def.h
  /opt/local/include/php83/php/Zend/zend_vm_execute.h
  /opt/local/include/php83/php/Zend/zend_vm_handlers.h
  /opt/local/include/php83/php/Zend/zend_vm_opcodes.h
  /opt/local/include/php83/php/Zend/zend_vm_trace_handlers.h
  /opt/local/include/php83/php/Zend/zend_vm_trace_lines.h
  /opt/local/include/php83/php/Zend/zend_vm_trace_map.h
  /opt/local/include/php83/php/Zend/zend_weakrefs.h
  /opt/local/include/php83/php/Zend/zend_weakrefs_arginfo.h
  /opt/local/include/php83/php/ext/date/lib/timelib.h
  /opt/local/include/php83/php/ext/date/lib/timelib_config.h
  /opt/local/include/php83/php/ext/date/php_date.h
  /opt/local/include/php83/php/ext/dom/xml_common.h
  /opt/local/include/php83/php/ext/filter/php_filter.h
  /opt/local/include/php83/php/ext/hash/php_hash.h
  /opt/local/include/php83/php/ext/hash/php_hash_adler32.h
  /opt/local/include/php83/php/ext/hash/php_hash_crc32.h
  /opt/local/include/php83/php/ext/hash/php_hash_fnv.h
  /opt/local/include/php83/php/ext/hash/php_hash_gost.h
  /opt/local/include/php83/php/ext/hash/php_hash_haval.h
  /opt/local/include/php83/php/ext/hash/php_hash_joaat.h
  /opt/local/include/php83/php/ext/hash/php_hash_md.h
  /opt/local/include/php83/php/ext/hash/php_hash_murmur.h
  /opt/local/include/php83/php/ext/hash/php_hash_ripemd.h
  /opt/local/include/php83/php/ext/hash/php_hash_sha.h
  /opt/local/include/php83/php/ext/hash/php_hash_sha3.h
  /opt/local/include/php83/php/ext/hash/php_hash_snefru.h
  /opt/local/include/php83/php/ext/hash/php_hash_tiger.h
  /opt/local/include/php83/php/ext/hash/php_hash_whirlpool.h
  /opt/local/include/php83/php/ext/hash/php_hash_xxhash.h
  /opt/local/include/php83/php/ext/json/php_json.h
  /opt/local/include/php83/php/ext/json/php_json_parser.h
  /opt/local/include/php83/php/ext/json/php_json_scanner.h
  /opt/local/include/php83/php/ext/libxml/php_libxml.h
  /opt/local/include/php83/php/ext/mysqlnd/config-win.h
  /opt/local/include/php83/php/ext/mysqlnd/mysql_float_to_double.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd_alloc.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd_auth.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd_block_alloc.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd_charset.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd_commands.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd_connection.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd_debug.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd_enum_n_def.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd_ext_plugin.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd_libmysql_compat.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd_plugin.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd_portability.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd_priv.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd_protocol_frame_codec.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd_ps.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd_read_buffer.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd_result.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd_result_meta.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd_reverse_api.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd_statistics.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd_structs.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd_vio.h
  /opt/local/include/php83/php/ext/mysqlnd/mysqlnd_wireprotocol.h
  /opt/local/include/php83/php/ext/mysqlnd/php_mysqlnd.h
  /opt/local/include/php83/php/ext/pcre/php_pcre.h
  /opt/local/include/php83/php/ext/pdo/php_pdo.h
  /opt/local/include/php83/php/ext/pdo/php_pdo_driver.h
  /opt/local/include/php83/php/ext/pdo/php_pdo_error.h
  /opt/local/include/php83/php/ext/phar/php_phar.h
  /opt/local/include/php83/php/ext/random/php_random.h
  /opt/local/include/php83/php/ext/session/mod_files.h
  /opt/local/include/php83/php/ext/session/mod_user.h
  /opt/local/include/php83/php/ext/session/php_session.h
  /opt/local/include/php83/php/ext/simplexml/php_simplexml.h
  /opt/local/include/php83/php/ext/simplexml/php_simplexml_exports.h
  /opt/local/include/php83/php/ext/spl/php_spl.h
  /opt/local/include/php83/php/ext/spl/spl_array.h
  /opt/local/include/php83/php/ext/spl/spl_directory.h
  /opt/local/include/php83/php/ext/spl/spl_dllist.h
  /opt/local/include/php83/php/ext/spl/spl_engine.h
  /opt/local/include/php83/php/ext/spl/spl_exceptions.h
  /opt/local/include/php83/php/ext/spl/spl_fixedarray.h
  /opt/local/include/php83/php/ext/spl/spl_functions.h
  /opt/local/include/php83/php/ext/spl/spl_heap.h
  /opt/local/include/php83/php/ext/spl/spl_iterators.h
  /opt/local/include/php83/php/ext/spl/spl_observer.h
  /opt/local/include/php83/php/ext/standard/base64.h
  /opt/local/include/php83/php/ext/standard/basic_functions.h
  /opt/local/include/php83/php/ext/standard/basic_functions_arginfo.h
  /opt/local/include/php83/php/ext/standard/crc32.h
  /opt/local/include/php83/php/ext/standard/crc32_x86.h
  /opt/local/include/php83/php/ext/standard/credits.h
  /opt/local/include/php83/php/ext/standard/credits_ext.h
  /opt/local/include/php83/php/ext/standard/credits_sapi.h
  /opt/local/include/php83/php/ext/standard/crypt_blowfish.h
  /opt/local/include/php83/php/ext/standard/crypt_freesec.h
  /opt/local/include/php83/php/ext/standard/css.h
  /opt/local/include/php83/php/ext/standard/datetime.h
  /opt/local/include/php83/php/ext/standard/dir_arginfo.h
  /opt/local/include/php83/php/ext/standard/dl.h
  /opt/local/include/php83/php/ext/standard/dl_arginfo.h
  /opt/local/include/php83/php/ext/standard/exec.h
  /opt/local/include/php83/php/ext/standard/file.h
  /opt/local/include/php83/php/ext/standard/file_arginfo.h
  /opt/local/include/php83/php/ext/standard/flock_compat.h
  /opt/local/include/php83/php/ext/standard/fsock.h
  /opt/local/include/php83/php/ext/standard/head.h
  /opt/local/include/php83/php/ext/standard/html.h
  /opt/local/include/php83/php/ext/standard/html_tables.h
  /opt/local/include/php83/php/ext/standard/info.h
  /opt/local/include/php83/php/ext/standard/md5.h
  /opt/local/include/php83/php/ext/standard/pack.h
  /opt/local/include/php83/php/ext/standard/pageinfo.h
  /opt/local/include/php83/php/ext/standard/php_array.h
  /opt/local/include/php83/php/ext/standard/php_assert.h
  /opt/local/include/php83/php/ext/standard/php_browscap.h
  /opt/local/include/php83/php/ext/standard/php_crypt.h
  /opt/local/include/php83/php/ext/standard/php_crypt_r.h
  /opt/local/include/php83/php/ext/standard/php_dir.h
  /opt/local/include/php83/php/ext/standard/php_dns.h
  /opt/local/include/php83/php/ext/standard/php_ext_syslog.h
  /opt/local/include/php83/php/ext/standard/php_filestat.h
  /opt/local/include/php83/php/ext/standard/php_fopen_wrappers.h
  /opt/local/include/php83/php/ext/standard/php_http.h
  /opt/local/include/php83/php/ext/standard/php_image.h
  /opt/local/include/php83/php/ext/standard/php_incomplete_class.h
  /opt/local/include/php83/php/ext/standard/php_lcg.h
  /opt/local/include/php83/php/ext/standard/php_mail.h
  /opt/local/include/php83/php/ext/standard/php_math.h
  /opt/local/include/php83/php/ext/standard/php_mt_rand.h
  /opt/local/include/php83/php/ext/standard/php_net.h
  /opt/local/include/php83/php/ext/standard/php_password.h
  /opt/local/include/php83/php/ext/standard/php_rand.h
  /opt/local/include/php83/php/ext/standard/php_random.h
  /opt/local/include/php83/php/ext/standard/php_smart_string.h
  /opt/local/include/php83/php/ext/standard/php_smart_string_public.h
  /opt/local/include/php83/php/ext/standard/php_standard.h
  /opt/local/include/php83/php/ext/standard/php_string.h
  /opt/local/include/php83/php/ext/standard/php_uuencode.h
  /opt/local/include/php83/php/ext/standard/php_var.h
  /opt/local/include/php83/php/ext/standard/php_versioning.h
  /opt/local/include/php83/php/ext/standard/proc_open.h
  /opt/local/include/php83/php/ext/standard/quot_print.h
  /opt/local/include/php83/php/ext/standard/scanf.h
  /opt/local/include/php83/php/ext/standard/sha1.h
  /opt/local/include/php83/php/ext/standard/streamsfuncs.h
  /opt/local/include/php83/php/ext/standard/url.h
  /opt/local/include/php83/php/ext/standard/url_scanner_ex.h
  /opt/local/include/php83/php/ext/standard/user_filters_arginfo.h
  /opt/local/include/php83/php/ext/standard/winver.h
  /opt/local/include/php83/php/ext/xml/expat_compat.h
  /opt/local/include/php83/php/ext/xml/php_xml.h
  /opt/local/include/php83/php/ext/xml/xml_arginfo.h
  /opt/local/include/php83/php/main/SAPI.h
  /opt/local/include/php83/php/main/build-defs.h
  /opt/local/include/php83/php/main/fastcgi.h
  /opt/local/include/php83/php/main/fopen_wrappers.h
  /opt/local/include/php83/php/main/http_status_codes.h
  /opt/local/include/php83/php/main/main_arginfo.h
  /opt/local/include/php83/php/main/php.h
  /opt/local/include/php83/php/main/php_compat.h
  /opt/local/include/php83/php/main/php_config.h
  /opt/local/include/php83/php/main/php_content_types.h
  /opt/local/include/php83/php/main/php_getopt.h
  /opt/local/include/php83/php/main/php_globals.h
  /opt/local/include/php83/php/main/php_ini.h
  /opt/local/include/php83/php/main/php_ini_builder.h
  /opt/local/include/php83/php/main/php_main.h
  /opt/local/include/php83/php/main/php_memory_streams.h
  /opt/local/include/php83/php/main/php_network.h
  /opt/local/include/php83/php/main/php_odbc_utils.h
  /opt/local/include/php83/php/main/php_open_temporary_file.h
  /opt/local/include/php83/php/main/php_output.h
  /opt/local/include/php83/php/main/php_reentrancy.h
  /opt/local/include/php83/php/main/php_scandir.h
  /opt/local/include/php83/php/main/php_streams.h
  /opt/local/include/php83/php/main/php_syslog.h
  /opt/local/include/php83/php/main/php_ticks.h
  /opt/local/include/php83/php/main/php_variables.h
  /opt/local/include/php83/php/main/php_version.h
  /opt/local/include/php83/php/main/rfc1867.h
  /opt/local/include/php83/php/main/snprintf.h
  /opt/local/include/php83/php/main/spprintf.h
  /opt/local/include/php83/php/main/streams/php_stream_context.h
  /opt/local/include/php83/php/main/streams/php_stream_filter_api.h
  /opt/local/include/php83/php/main/streams/php_stream_glob_wrapper.h
  /opt/local/include/php83/php/main/streams/php_stream_mmap.h
  /opt/local/include/php83/php/main/streams/php_stream_plain_wrapper.h
  /opt/local/include/php83/php/main/streams/php_stream_transport.h
  /opt/local/include/php83/php/main/streams/php_stream_userspace.h
  /opt/local/include/php83/php/main/streams/php_streams_int.h
  /opt/local/include/php83/php/main/streams/userspace_arginfo.h
  /opt/local/include/php83/php/sapi/cli/cli.h
  /opt/local/lib/php83/build/Makefile.global
  /opt/local/lib/php83/build/ax_check_compile_flag.m4
  /opt/local/lib/php83/build/ax_gcc_func_attribute.m4
  /opt/local/lib/php83/build/config.guess
  /opt/local/lib/php83/build/config.sub
  /opt/local/lib/php83/build/gen_stub.php
  /opt/local/lib/php83/build/libtool.m4
  /opt/local/lib/php83/build/ltmain.sh
  /opt/local/lib/php83/build/php.m4
  /opt/local/lib/php83/build/php_cxx_compile_stdcxx.m4
  /opt/local/lib/php83/build/phpize.m4
  /opt/local/lib/php83/build/pkg.m4
  /opt/local/lib/php83/build/run-tests.php
  /opt/local/lib/php83/build/shtool
  /opt/local/share/man/man1/php-config83.1.gz
  /opt/local/share/man/man1/php83.1.gz
  /opt/local/share/man/man1/phpize83.1.gz
  /opt/local/var/db/php83/.turd_php83

Could anyone help me to find out what folder I should copy to MAMP? Any advice is welcome!

Thanks in advance!

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