Server Sent Events from PHP in Block

I would like to ask you, how can I use the Server Sent Events if I have my PHP written inside of a block.
The issue is that when I want to ask for an event in the PHP using SSE, I have to use the name of the php script like it is in the example below:

var evtSource = new EventSource(“somescript.php“);

Any suggestion, how to direct my javascript to a php script in body?

Thank you a lot!

Drupal version: