DEV Community

Adamo Crespi for Serendipity HQ

Posted on • Originally published at io.serendipityhq.com on

A useful php.ini configuration for local development

Here there is a good configuration for your PHP environment. It is a good checklist to use, for example, when you update MAMP.

Open your php.ini, located at /Applications/MAMP/bin/php/php5.6.10/conf/php.ini.

Keep attention to the version of PHP you are using with MAMP!

Then, find those lines and edit them:

  • Higher the memory_limit. I’ve set it to 1073741824, that is 1GB 🙂 (using the amount in bytes instead of in MB):
memory_limit = 1073741824 ; Maximum amount of memory a script may consume (1GB)
Enter fullscreen mode Exit fullscreen mode
  • Set the error reporting to E-ALL:
; error_reporting is a bit-field. Or each number up to get desired error
; reporting level
; E_ALL - All errors and warnings
; E_ERROR - fatal run-time errors
; E_WARNING - run-time warnings (non-fatal errors)
; E_PARSE - compile-time parse errors
; E_NOTICE - run-time notices (these are warnings which often result
; from a bug in your code, but it's possible that it was
; intentional (e.g., using an uninitialized variable and
; relying on the fact it's automatically initialized to an
; empty string)
; E_CORE_ERROR - fatal errors that occur during PHP's initial startup
; E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's
; initial startup
; E_COMPILE_ERROR - fatal compile-time errors
; E_COMPILE_WARNING - compile-time warnings (non-fatal errors)
; E_USER_ERROR - user-generated error message
; E_USER_WARNING - user-generated warning message
; E_USER_NOTICE - user-generated notice message
;
; Examples:
;
; - Show all errors, except for notices
;
;error_reporting = E_ALL & ~E_NOTICE
;
; - Show only errors
;
;error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR
;
; - Show all errors except for notices
;
error_reporting = E_ALL
Enter fullscreen mode Exit fullscreen mode
  • Display errors, so you can see all the errors produced by your app:
; Print out errors (as a part of the output). For production web sites,
; you're strongly encouraged to turn this feature off, and use error logging
; instead (see below). Keeping display_errors enabled on a production web site
; may reveal security information to end users, such as file paths on your Web
; server, your database schema or other information.
display_errors = On
Enter fullscreen mode Exit fullscreen mode
  • Display startup errors, that is useful, for example, to intercept errors caused by new PHP extensions installed, as Intl, for example:
; Even when display_errors is on, errors that occur during PHP's startup
; sequence are not displayed. It's strongly recommended to keep
; display_startup_errors off, except for when debugging.
display_startup_errors = On
Enter fullscreen mode Exit fullscreen mode
  • Set the error_log directory: it may happen that a blank page appears and this is the only way to know what happened.
; Log errors to specified file. PHP's default behavior is to leave this value
; empty.
; http://php.net/error-log
; Example:
error_log = php_errors.log
; Log errors to syslog (Event Log on Windows).
;error_log = syslog
Enter fullscreen mode Exit fullscreen mode
  • Set the default timezone:
[Date]
; Defines the default timezone used by the date functions
; Will be changed by MAMP to system timezone
date.timezone = "Europe/Rome"
Enter fullscreen mode Exit fullscreen mode

Those are the base modifications you have to do to have a good development environment.

Maybe you want also activate some extensions and this requires edit the php.ini file too:

WARNING!

Setting all the errors to be shown is the worst practice in production as those errors may provide an attacker a lot of useful information about your system: on production, ever turn off all the errors! Ever!

Remember to “Make. Ideas. Happen.”.

I wish you flocking users, see you soon!

L'articolo A useful php.ini configuration for local development proviene da ÐΞV Experiences by Serendipity HQ.

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay