Back

How to load and instantiate PHP files from storage/app


neromaki posted 2 years ago

Hello,

Basic run-down of my system:

Users upload a PHP file containing a bot class which will be used to compete with other uploaded bots in games.

Question

How would I be able to load in these uploaded PHP classes from storage to instantiate and use them?

Would I need to use Service Containers, Packages or such for this? (I couldn't really understand the situations you would use them in)

Psuedo-code:

function loadBots() {
    include('storage/app/bot.php');
    $bot->do = new Bot();
    $bot->do->botStuff();
}

What I've Tried

  • Loading in the PHP file via Storage::get() (this appears to just read it as a text file)
  • include(storage/app/folder/bot.php) isn't able to access storage

Sign in to participate in this thread!



We'd like to thank these amazing companies for supporting us