Due to security reasons, php filter module has been removed from Drupal 8. It caused adding php scripts in blocks and nodes very difficult. To overcome this problem we have created our own module and pushed it as sandbox project in Drupal.org
Php Shortcode - This modules provides shortcode option to execute php scripts inside blocks and nodes.
Dependencies:- Shortcode module
Project URL:- https://www.drupal.org/sandbox/niyas/2780793
Steps to use this module:-
1) Install and enable 'Php Shortcode' Module.
2) Go to Configuration > Content Authoring > Text Formats.
3)Find the input format you want to enable the shortcode for and click on Configure in that row.
4) Enable the shortcode filter Shortcodes.
5) Under Filter settings, check the checkbox next to 'Enable Php Code Shortcode'.
6) Save the settings.
You're done. Now If you go and create any custom block you would notice below the WYSIWYG editor is our helpful tip to users on how to use the php shortcode.
After saving the block, Here is the output:-
Please try this module by downloading here and let us know if you have any questions.