Settings > Languages > PHP
PHP (Hypertext Preprocessor) is a widely used open-source scripting language that is particularly well-suited for web development and can be embedded in HTML. It is easy to learn and apply. One of the major advantages of PHP is its seamless integration with various database systems and services. MAMP PRO offers a wide range of different PHP versions to cater to the specific needs and requirements of developers, creating the optimal working environment. Additionally, MAMP PRO provides various cache modules to choose from and already integrates the most commonly used extensions. Error logging can also be configured granularly.
-
Default version
Here, you define which PHP version should be selected by default when creating a new site. However, you can change this setting later for the site, providing you with flexibility in choosing the PHP version for your project. If the corresponding checkbox is activated, the selected PHP version will also be used for the command line shortcut.-
Plus
MAMP PRO already includes a large number of different PHP versions by default, but even more can be added—whether older or newer versions. This allows you to test your project with a wide range of PHP versions and ensure maximum compatibility. A click on the plus button opens a dialog box with a list of additional available PHP versions. By clicking the “Install” button for the desired PHP version, it will be added to your development environment. After the installation, a restart of MAMP PRO is required. -
Minus
If you no longer need a specific PHP version or want to free up disk space, you can, of course, remove an installed PHP version. To do so, select the PHP version you want to remove and click the minus button. To prevent accidental deletion, MAMP PRO will ask for confirmation before removing the selected PHP version. -
Open template…
The php.ini file is the central configuration file for PHP, defining the behavior of the PHP environment. It manages settings such as the maximum script execution time, memory limit, error handling, file upload size, and the activation of extensions. This allows you to control which functions are available and how PHP operates on the server.MAMP PRO also uses php.ini files, but these are based on special template files. These templates include default values and placeholders, which are replaced with the corresponding values when MAMP PRO starts. Each PHP version has its own template file to ensure maximum flexibility.
While many settings can be adjusted directly through the MAMP PRO interface, less frequently used values can be modified by editing the template files. Be cautious when doing so—incorrect entries or syntax errors may lead to unexpected results, including the failure of servers and services to start.
-
Activate command line shortcuts for the selected PHP version
Using PHP via a command-line shortcut can be useful as it provides a fast and efficient way to execute PHP scripts directly from the command line. This is especially beneficial for developers who regularly work with PHP and want to perform quick tests. Additionally, the command line can be used for automating tasks or debugging scripts, allowing direct access to console outputs. PHP extensions can also be installed via PECL using the command line. MAMP PRO uses aliases to provide this functionality. When this option is enabled, the following is added to your ‘~/.profile’ file, allowing for quick access through the command line.alias php='/Applications/MAMP/bin/php/phpx.x.x/bin/php -c "/Library/Application Support/appsolute/MAMP PRO/conf/phpx.x.x.ini"' alias php-config='/Applications/MAMP/bin/php/phpx.x.x/bin/php-config' alias phpdbg='/Applications/MAMP/bin/php/phpx.x.x/bin/phpdbg' alias phpize='/Applications/MAMP/bin/php/phpx.x.x/bin/phpize' alias pear='/Applications/MAMP/bin/php/phpx.x.x/bin/pear' alias peardev='/Applications/MAMP/bin/php/phpx.x.x/bin/peardev' alias pecl='/Applications/MAMP/bin/php/phpx.x.x/bin/pecl'
If you want to check whether the default PHP version set in MAMP PRO is accessible via the command line shortcut, you can do so using the following command:
php -v
Note: MAMP PRO also adds the path to the
bin
folder of the currently selected PHP version to the$PATH
variable in your~/.profile
file. Since this file will be sourced by thebash
andzsh
shells, do not make changes to$PATH
in other configuration files of these shells.export PATH="/Applications/MAMP/bin/php/phpx.x.x/bin"
-
Also activate shortcut for Composer
Composer is a dependency manager for PHP that allows you to manage libraries and packages for your projects. It simplifies the installation, updating, and management of PHP dependencies by using a central configuration file (composer.json). Having a command line shortcut for Composer is useful as it provides quick and easy access to Composer commands without needing to specify the full path to the Composer tool each time. This saves time and improves workflow, especially for frequent package installations or updates. MAMP PRO already includes Composer, so you can use it directly. When this option is enabled, the following is added to your ‘~/.profile’ file, making the Composer shortcut available for the command line:alias composer='/Applications/MAMP/bin/php/composer'
-
-
-
Cache module:
A cache module in PHP improves performance by storing frequently used data or pre-executed PHP scripts in memory, eliminating the need to process them on every request. This significantly reduces server load and shortens the loading times of web applications. MAMP PRO offers two options: APC (Alternative PHP Cache) and OPCache. Both modules store precompiled PHP scripts in memory, but they differ in functionality and use cases. APC is an older module that, in addition to opcode caching, also allows caching of arbitrary data such as intermediate results or objects, which is particularly useful for complex applications. OPCache, on the other hand, focuses solely on caching PHP bytecode, making it more stable, faster, and officially bundled with PHP. OPCache is the preferred choice, especially for modern PHP versions, as it provides better integration and performance. APC can still be useful in specific cases where a custom data cache is required in addition to opcode caching.Several caches offer a user interface to help analyze and profile your code. Click the arrow button next to the cache name to access this interface. The interface will not be available if the arrow button is disabled.
-
off
Select this option if you do not want to use any PHP cache module. Disabling caching can be useful in development environments where you need to ensure that every change to your PHP scripts is immediately applied without the risk of outdated cached versions being served. It allows for easier debugging and testing, as the code is executed fresh on each request. However, keep in mind that this may lead to slower performance compared to using a cache module, especially in production environments. -
APC
The Alternative PHP Cache (APC) is a free and open-source opcode cache for PHP that improves performance by caching compiled PHP code in memory, reducing the need for repeated compilation. In addition to opcode caching, APC provides a user cache, allowing developers to store custom data such as variables or objects for faster access. This makes APC particularly useful for applications that require caching not only PHP scripts but also application-specific data. While APC is less commonly used in modern environments due to the introduction of OPCache, it remains a solid choice when you need both opcode caching and shared user caching functionality. You can learn more about APC here. -
OPCache
OPcache improves PHP performance by caching precompiled script bytecode in shared memory, which removes the need for PHP to load, parse, and compile scripts on every request. This results in faster execution times, reduced CPU usage, and an overall more efficient use of server resources. As it is bundled with PHP and actively maintained, OPcache is the default and most widely recommended opcode caching solution for modern PHP versions. It is particularly beneficial in production environments, where performance and scalability are critical, as it helps reduce response times and supports a higher number of concurrent requests. Unlike APC, OPcache is focused solely on opcode caching and does not include a user cache for custom data storage, which makes it simpler, more stable, and optimized for maximum script execution speed. For most use cases, especially with current PHP versions, OPcache is the preferred choice for achieving consistent high performance and stability. You can learn more about OPcache here.
-
-
Extensions:
In MAMP PRO, the ‘Extensions’ setting allows you to enable or disable important PHP extensions to customize the functionality of PHP. Xdebug is a debugging tool that makes it easier to troubleshoot and provides detailed insights into your code. Imagick (ImageMagick) enables image processing and manipulation directly in PHP, supporting numerous image formats. Tidy helps analyze and clean up HTML code to produce clean, standards-compliant markup. OAuth is an extension for secure authentication and authorization via external services and is commonly used for connecting to third-party APIs.
-
Xdebug (Debugger)
Activate Xdebug to enable debugging and profiling capabilities in PHP. Xdebug provides detailed information about the execution of your PHP scripts, helping you identify errors, track the flow of execution, and inspect variables in real time. It is commonly used to improve the development and debugging process by integrating with IDEs and debuggers, such as MacGDBp, for step-by-step code analysis. By default, Xdebug listens on localhost and port9000
as specified in the php.ini file. For more detailed instructions on using Xdebug with the MacGDBp Debugger, you can refer to our FAQ article. -
Imagick / ImageMagick
If you activate this checkbox, Imagick (the PHP extension) and ImageMagick (the underlying software) will be available. Imagick provides a powerful set of tools for creating, editing, and converting images in various formats directly within PHP. It allows you to manipulate images by resizing, cropping, applying filters, and performing other image transformations. ImageMagick is the underlying image processing library that supports a wide range of image formats and operations. By enabling this extension, you can integrate advanced image manipulation capabilities into your PHP-based applications. For more information, you can refer to the official documentation for Imagick and ImageMagick. -
Tidy
If you activate this checkbox, Tidy will be available. Tidy is a PHP extension that helps clean up and format HTML code, ensuring it is well-structured and adheres to web standards. It can automatically correct syntax errors, remove redundant tags, and improve the overall readability and consistency of HTML documents. Tidy is particularly useful for working with legacy HTML or content that is prone to formatting issues. By enabling this extension, you can ensure your HTML is clean, error-free, and properly formatted. For more details, you can refer to the official documentation for Tidy. -
Oauth
If you activate this checkbox, OAuth will be available. OAuth is an open standard for authorization that allows secure, token-based authentication between a client and a server. It enables users to grant third-party applications limited access to their resources without sharing their login credentials. This is commonly used for integrating external services, such as social media logins or API access, into your applications. By enabling this extension, you can implement OAuth-based authentication and authorization in your PHP applications, providing a secure and standardized way for users to authenticate. For more details, you can refer to the official documentation for Oauth. -
Enable other extensions…
Clicking this button opens the internal template file used for the php.ini configuration in an editor window, allowing you to manage additional PHP extensions. This feature enables you to customize your PHP environment by activating or configuring other extensions not listed in the default MAMP PRO interface. By modifying the template file, you gain more flexibility and control over your PHP setup. More information about this template file and how to customize it can be found here.
-
-
Log:
Here, you define the type of messages to be reported and where they should be written.For information about PHP error handling, refer to the PHP documentation in the “error_reporting” section. Please note: The option
E_ALL
option includes more than justE_ERROR
,E_WARNING
andE_NOTICE
(see “Predefined Constants”).-
Initialization errors
Log any errors that occur when Apache loads the PHP module. -
All messages (E_ALL)
If you activate this checkbox, all messages will be reported. This option corresponds to theE_ALL
setting. -
Errors (E_ERROR)
If you activate this checkbox, all errors will be reported. This option corresponds to theE_ERROR
setting. -
Warnings (E_WARNING)
If you activate this checkbox, all warnings will be reported. This option corresponds to theE_WARNING
setting. -
Notices (E_NOTICE)
If you activate this checkbox, all notices will be reported. This option corresponds to theE_NOTICE
setting. -
Other
Report additional error types using constants. -
to screen
Activate this checkbox if you want the messages to appear on your website. -
to file
Activate this checkbox if you want the messages to be written to a file.- Choose…
Here, you can choose the directory and file name. By default, the message is written to the file “/Applications/MAMP PRO/logs/php_error.log”.
- Choose…
-