PHP:消息传递/日志记录到Eclipse控制台?

PHP:消息传递/日志记录到Eclipse控制台?

问题描述:

Is it possible to send messages from a PHP script to the console in Eclipse? Has anyone attempted this already? I'm not very familiar with how the console works, so I'm not sure if there is a standardized method for communicating with it.

是否可以在Eclipse中将消息从PHP脚本发送到控制台? 有没有人尝试过这个? 我不太熟悉控制台的工作方式,所以我不确定是否有标准化的方法与之通信。 p> div>

If you look at...

Main Menu -> Run -> External Tools -> Open External Tools Dialog.

In there I have set up PHP Codesniffer with the following...

  • Name : Code Sniffer
  • Location : /usr/bin/phpcs
  • Working Directory : ${workspace_loc}
  • Arguments : --standard=${resource_loc}

That runs the codesniffer as an external tool and all the messages it returns appear in the console. Once you have set it up, click the down arrow and choose "Code Sniffer" and then anything the external program (in this case codesniffer) outputs will be in the Eclipse console.

If you set it up like this...

  • Name : PHP
  • Location : /usr/bin/phpcs
  • Working Directory : ${workspace_loc}
  • Arguments : ${workspace_loc}${resource_path}

It will just run php in CLI mode and if you run it with Wilco's code (above) you will get.

Hello World

In the terminal.

Hope that helps.

All output from an Eclipse external tool launch goes to the console by default, so if you execute a PHP script using an external tool launcher any output from the script will go to the console.

For example:

<?php

echo "Hello World
";

?>

Will send "Hello World" to the console.

Any echo or print you do should go to the console automatically. This has been very unreliable for a long time, however. Please vote to have this bug fixed at:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=282997