How to display phpinfo() within Laravel for debugging PHP?

Viewed 11942

What is the easiest way to display PHP configuration using

phpinfo();

in a Laravel application, to debug local PHP configuration in a development environment?

Background:

I need to find out on my Mac, where brew placed the php.ini file which is read.

4 Answers

For Laravel ..routes\web.php

add:

    Route::get('phpmyinfo', function () {
    phpinfo(); 
})->name('phpmyinfo');

Then in your URL type yourdomain.com/phpmyinfo

Go to Laravel folder

/public

open

index.php

Look for the comment block

|---------------------
| Run The Application
|---------------------

Under that block just place

phpinfo();

Then start Laravel application with

php artisan serve

And open the application in browser. Don't forget to remove the line.

Please note:

This is only for local debugging purposes, as you reveal confidential information about PHP config.

Using phpinfo(); like that is usually only needed if you are trying to figure out the configuration the webserver is using for PHP. From the CLI this is not needed.

php --ini

If you want a separate Info file for debugging purpose only

Go to project root folder

cd public

nano phpinfo.php

<?php

// Show all information, defaults to INFO_ALL
phpinfo();

?>

Run Laravel : php artisan serve

VIEW YOUR PHPINFO PAGE

To view your php info page, open a browser and go to the URL http://localhost/phpinfo.php

Please note:

This is only for local debugging purposes, You expose everything in this file , Remove this before putting code in production

Related