So within administrator function.

echo("<script>console.log('PHP: " . $data . "');</script>");

It seems it doesn't insert the js script on the page. This works from a simple PHP file, but not from Joomla. Any ideas?

1 Answer 1


You can use Joomla's Web Asset Manager to insert inline scripts via PHP, like so:

use Joomla\CMS\Factory;

$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
$wa->addInlineScript('console.log("PHP: ' . $data . '")');
  • Thanks, but the file which I want to debug looks like doesn't output anything at all. "\libraries\src\Form\Field\CalendarField.php"
    – Plamen
    Apr 2 at 5:31
  • Can you not just var_dump($data)?
    – Lodder
    Apr 2 at 6:07
  • Noting out. This is from "Articles: Edit - Publishing tab". Not sure, but no HTML output from CalendarField.php.
    – Plamen
    Apr 2 at 9:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.