We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

[SOLVED] PHP in templates with autoload

Development and Programming

vw000's avatar
vw000
241 posts
4 years ago
vw000's avatar vw000

Can Expression Engine use PHP in templates that needs to autoload files?

Example:

require_once ‘/path/to/vendor/autoload.php’;

use Custom\Classes;

       
Andy McCormick's avatar
Andy McCormick
183 posts
4 years ago
Andy McCormick's avatar Andy McCormick

Sure. You just have to have PHP enabled in the template. Once you do that, any PHP code is parsed just as it would be in a standard PHP file.

       
vw000's avatar
vw000
241 posts
4 years ago
vw000's avatar vw000

Thank you, I will test it.

       
Andy McCormick's avatar
Andy McCormick
183 posts
4 years ago
Andy McCormick's avatar Andy McCormick

@vw000, just to confirm did this work as expected?

       
vw000's avatar
vw000
241 posts
4 years ago
vw000's avatar vw000

I haven’t tested this yet. I was going to use something from Github that required autoload but decided to code something from scratch instead.

       
Andy McCormick's avatar
Andy McCormick
183 posts
4 years ago
Andy McCormick's avatar Andy McCormick

ok. I’m going to mark this as solved for now. Please feel free to ping me back on here if you try it and it doesn’t work.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.