Reputation: 31307
Each time I want to see the phpinfo();
I have to:
phpinfo();
in it.I'm on Ubuntu.
Isn't there a more practical way to see phpinfo in the browser?
Upvotes: 183
Views: 344838
Reputation: 9052
PHP CLI PHPInfo()
html
solution in Windows
If you need the phpinfo html without having wampp or xampp or apache, do this in command line (remember the directory you run this command in ie. Desktop):
php -S localhost:<random_port> // I used port 7912 in this case
This will start the built-in php development server:
[Wed Oct 2 08:57:17 2024] PHP 8.3.12 Development Server (http://localhost:7912) started
Then in a new command line window in the same directory where you ran the above command (ie. Desktop), create a phpinfo.php
file:
echo|set /p="<?php phpinfo(); ?>" >> phpinfo.php
Now we can output the phpinfo()
html into a file:
php -r "echo shell_exec('curl -L http://localhost:7912/phpinfo.php');" > phpinfo.html
You can now stop the server in the first command line window by pressing CTRL + C
Upvotes: 0
Reputation: 13475
From your command line you can run..
php -i
I know it's not the browser window, but you can't see the phpinfo();
contents without making the function call.
Another approach would be to have a PHP script in the root of your web server directory that calls phpinfo();
, that way you have access to it at all times via http://localhost/info.php
or something similar. However, this is NOT suitable for a production environment unless you ensure that you secure it.
EDIT: As mentioned by binaryLV, its quite common to have two versions of a php.ini per installation. One for the command line interface (CLI) and the other for the web server interface. If you want to see phpinfo output for your web server make sure you specify the ini file path, for example...
php -c /etc/php/apache2/php.ini -i
Upvotes: 343
Reputation: 742
You can use this command to print phpinfo to file .txt:
touch phpinfo.txt && php -i >> phpinfo.txt && sudo gedit phpinfo.txt
Explain about that code:
touch phpinfo.txt
php -i >> phpinfo.txt
sudo gedit phpinfo.txt
Hope it's help. Thanks.
Upvotes: 3
Reputation: 51
If you are using WAMP then type the following in the browser
http://localhost/?phpinfo=-1,
you will get the phpinfo page.
You can also click the localhost icon in the wamp menu from the systray and then find the phpinfo page. WAMP localhost from WAMP Menu
Upvotes: 0
Reputation: 10760
From the CLI the best way is to use grep
like:
php -i | grep libxml
Upvotes: 27
Reputation: 6593
If you have php installed on your local machine try:
$ php -a
Interactive shell
php > phpinfo();
Upvotes: 29
Reputation: 3981
Use the command line.
touch /var/www/project1/html/phpinfo.php && echo '<?php phpinfo(); ?>' >> /var/www/project1/html/phpinfo.php && firefox --url localhost/project1/phpinfo.php
Something like that? Idk!
Upvotes: 4