Location of php ini in xampp

I am having trouble with the php versions on my mac. When I am in terminal i get the php mac version.

I tried to install Yii2 advanced, and could not run yii migrate. I also could not get a virtual host to work.

Lots of information, but I cannot figure it out.

I believe I need to set the path to the xampp php, so terminal looks at that first. How do I accomplish that?

Thanks, Dan

I am on the latest El Capitan, and as your probably aware, your Mac comes with php installed. This can be confusing. The CLI (running PHP from terminal) actually will use your Mac’s included PHP and not the one from XAMPP. So far I haven’t ran into any issues with this. It could pose a problem if the script your running in CLI requires a specific PHP module to be installed. It could be installed for XAMPP but not for your included PHP. Say Zend, you add it to XAMPP but run the script from terminal and boom, errors. As for Yii, I haven’t had any issues from command line.

Before giving you the answer, I am going to tell you how to find out which php.ini both are using.

Open Terminal and navigate to your htdocs:


cd /Applications/XAMPP/xamppfiles/htdocs

Create a phpinfo.php file:


touch phpinfo.php

Edit the file and enter in the command to make php spit out it’s guts:


nano phpinfo.php

the content:


<?php

phpinfo();



To save and exit:




cmd + o

cmd + x



Open the file in your browser:


http://localhost/phpinfo.php

Run the file in Terminal CLI:


php phpinfo.php

You can compare the differences. The one in terminal is what came with your Mac. I had version 5.5 where XAMP had 5.6. The included php version on mine has no php.ini loaded, error_reporting had no value. It does say that it looks in "/etc" for the ini file. Remember, that is for the PHP which came with your Mac and only applies to anything PHP that you run from terminal itself. What you are interested in, is the PHP Info you ran in your browser, as that is what XAMPP is using.

In your browser’s phpinfo that you opened, look for the line for “Loaded Configuration File”. Mine shows this:


Loaded Configuration File:          /Applications/XAMPP/xamppfiles/etc/php.ini

So there you go. XAMPP’s PHP.ini on a Mac is located at: /Applications/XAMPP/xamppfiles/etc/php.ini

I wanted to point out the differences for you to keep in mind in the future, in case you ever have issues from Terminal (the CLI = Command Line Interface). So you know you actually have 2 versions of PHP.


On a Mac, you have to do this:


./yii migrate

In the root of the Yii app is an executable file named "yii". In order to execute files on a Mac, you put "./" in front of it.

PHP | php.ini File Configuration

Improve Article

Save Article

Like Article

  • Difficulty Level : Basic
  • Last Updated : 28 Jan, 2022

  • Read
  • Discuss
  • Courses
  • Practice
  • Video
  • Improve Article

    Save Article

    At the time of PHP installation, php.ini is a special file provided as a default configuration file. It’s very essential configuration file which controls, what a user can or cannot do with the website. Each time PHP is initialized, the php.ini file is read by the system. Sometimes you need to change the behavior of PHP at runtime, then this configuration file is to use.
    All the settings related to register global variables, upload maximum size, display log errors, resource limits, the maximum time to execute a PHP script and others are written in a file as a set of directives which helps in declaring changes.
    Note: Whenever some changes are performed in the file, you need to restart our web server.
    It helps in easy administration of web server using these configuration files. We can also write our own custom configuration files.
    To check file path use the following program: 
     

    php




    <?php

    echo phpinfo();

    ?>

    Note: Keys in the file are case-sensitive, keyword values are not spaces and lines starting with a semicolon are ignored. The file is well commented. The Boolean values are represented by On/Off, 1/0, True/False, Yes/No.
    The file contains a set of directives with a set of respective values assigned to it. The values can be string, a number, a PHP constant, INI constants, or an expression, a quoted string or a reference to a previously set variable. Expression in the INI file is limited to bitwise operators or parentheses. Settings with a particular hostname will work under that particular host only.
    Environment variables of php.ini file: 
     

    • memory_limit: This setting is done to show the maximum amount of memory a script consumes.

    Important settings or common parameters of the php.ini file: 
     

    1. enable_safe_mode = on Its default setting to ON whenever PHP is compiled. Safe mode is most relevant to CGI use.
    2. register_globals = on its default setting to ON which tells that the contents of EGPCS (Environment, GET, POST, Cookie, Server) variables are registered as global variables. But due to a security risk, the user has to ensure if it set to OFF for all scripts.
    3. upload_max_filesize This setting is for the maximum allowed size for uploaded files in the scripts.
    4. upload_tmp_dir = [DIR] Don’t uncomment this setting.
    5. post_max_size This setting is for the maximum allowed size of POST data that PHP will accept.
    6. display_errors = off This setting will not allow showing errors while running PHP project in the specified host.
    7. error_reporting = E_ALL & ~E_NOTICE: This setting has default values as E_ALL and ~E_NOTICE which shows all errors except notices.
    8. error_prepend_string = [“”] This setting allow you to make different color of messages.
    9. max_execution_time = 30 Maximum execution time is set to seconds for any script to limit the time in production servers.
    10. short_open_tags = Off To use XML functions, we have to set this option as off.
    11. session.save-handler = files You don’t need to change anything in this setting.
    12. variables_order = EGPCS This setting is done to set the order of variables as Environment, GET, POST, COOKIE, SERVER. The developer can change the order as per the need also.
    13. warn_plus_overloading = Off This setting issues a warning if + used with strings in a form of value.
    14. gpc_order = GPC This setting has been GPC Deprecated.
    15. magic_quotes_gpc = on This setting is done in case of many forms are used which submits to themselves or others and display form values.
    16. magic_quotes_runtime = Off If magic_quotes_sybase is set to On, this must be Off, this setting escape quotes.
    17. magic_quotes_sybase = Off If this setting is set to off it should be off, this setting escape quotes.
    18. auto-prepend-file = [filepath] This setting is done when we need to automatically include() it at the beginning of every PHP file.
    19. auto-append-file = [filepath] This setting is done when we need to automatically include() it at the end of every PHP file.
    20. include_path = [DIR] This setting is done when we need to require files from the specified directories. Multiple directories are set using colons.
    21. ignore_user_abort = [On/Off] This settings control what will happen when the user click any stop button. The default value is on this setting doesn’t work on CGI mode it works on only module mode.
    22. doc_root = [DIR] This setting is done if we want to apply PHP to a portion of our website.
    23. file_uploads = [on/off] This flag is set to ON if file uploads are included in the PHP code.
    24. mysql.default_host = hostname This setting is done to connect to MySQL default server if no other server host is mentioned.
    25. mysql.default_user = username This setting is done to connect MySQL default username, if no other name is mentioned.
    26. mysql.default_password = password This setting is done to connect MySQL default password if no other password is mentioned.

    Configuration of php.ini file: Whenever we install PHP, we can locate the configuration file inside the PHP folder. If using xampp, we can find the configuration file in one or many versions, inside the path ‘\xampp\php’.
    Note: Other versions of this file are php.ini-development and php.ini-production. The most preferred one is php.ini-development file.
     

    My Personal Notes arrow_drop_up

    Save

    Please Login to comment...

    How do I access PHP ini?

    Your answer.
    You can get a full phpinfo() using : php -i..
    And, in there, there is the php.ini file used : $ php -i | grep 'Configuration File' Configuration File (php.ini) Path => /etc Loaded Configuration File => /etc/php.ini..
    On Windows use find instead: php -i|find/i"configuration file" Hope this is helpfull!!.

    Where is the PHP ini file located?

    ini file is the default configuration file for running applications that require PHP. It is used to control variables such as upload sizes, file timeouts, and resource limits. This file is located on your server in the /public_html folder.

    How do I open a PHP ini file in Windows?

    In Windows Explorer, open your PHP installation folder, for example C:\PHP . In a text editor, open the php. ini file. Search the file for the extension you want to configure.

    Where is my ini file in xampp?

    For Windows, you can find the file in the C:\xampp\php\php. ini -Folder (Windows) or in the etc -Folder (within the xampp-Folder). Under Linux, most distributions put lampp under /opt/lampp , so the file can be found under /opt/lampp/etc/php. ini .