Question

I can't get the auto_prepend_file setting in php.ini to work. I tested the path directly in the project folder I'm working on and it works seamlessly. Based off everything below, does anyone have some ideas as to what to try next? Any help would be greatly appreciated!

// This did nothing
ini_set("auto_prepend_file","/Applications/MAMP/bin/php/php5.5.10/prepend.php");

// This allowed it to work by including it in the index.php but it's not using the auto_append_file setting
require_once '/Applications/MAMP/bin/php/php5.5.10/conf/prepend.php';

Bash Commands Used:

# When I did this, it gave me the correct path
$ cat /Applications/MAMP/conf/php5.5.10/php.ini | grep auto_prepend_file
auto_prepend_file ="/Applications/MAMP/bin/php/php5.5.10/conf/prepend.php" 

# But when I ran this command, it shows that there are no values (just like it does when running phpinfo() )
$ php -i | grep auto_prepend_file
auto_prepend_file => no value => no value

# Nothing is output when I run this command
$ php -r "echo ini_get('auto_prepend_file');"

The php.ini paths from phpinfo()

Configuration File (php.ini) Path   /Applications/MAMP/bin/php/php5.5.10/conf

Loaded Configuration File   /Library/Application Support/appsolute/MAMP PRO/conf/php.ini

I found a ton of php.ini files on my system

/Library/Application Support/appsolute/MAMP PRO/conf/php.ini
/Applications/MAMP/conf/php5.5.10/php.ini
/Users/alexcory/jarvis/tmp/backup/php.ini~

// Not sure if these have any effect
/private/etc/php-fpm.conf.default
/private/etc/php.ini.default

Contents of prepend.php

<?php
die('Hello World');                 // Haven't been able to get "Hello World" to show

require_once dirname( _file_ ) . '/kint/Kint.class.php';

StackOverflow questions referenced.

auto_prepend_file is not working in cli mode

Why would auto_prepend_file works in .htaccess but not in php.ini?

php version issue in auto_prepend_file

Was it helpful?

Solution

MAMP allows you to open the php.ini file from within the application by going to File ▶ Edit Template ▶PHP ▶ php {version} php.ini.

That should open the php.ini in an editor such as a TextEdit. I hope that helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top