Scripts

How do I use PHP in Drupal 8?

Drupal Loves PHP, but it loves MVC and OOP now too!

I have to admit, I'm partially writing this post just to see in my analytics reporting how many people are searching for it. But for those that are trying to wedge PHP into Drupal8 and having trouble with it, there is something here for you.

The PHP Filter has been moved out of core and is now a contib module. It was also not working during the release-candidate phase of Drupal 8, but seems to be back on track now. Sometimes people like to do crazy things like create a Panels page at a certain URL and then enable the PHP text filter. If you're slick you might do an include() or an include_once() command and call your scripts from a directory where they can be managed in a code repository and such.

But it's a drag creating a huge Panels page, with all its features, just to call an include() command. And you have to create a Panel for each path (or route) you want to bring into existence. This is pretty heavy for just having a route to call a script.

Tags: 

Subscribe to RSS - Scripts