Open ghost opened 10 years ago
Classes need the correct namespace at the top of the file, otherwise the auto-loader will be looking in the wrong place.
Where is this current class defined and what namespace have you given it?
As an example If it's a command the namespace should be "Command" and the file should be contained inside the Classes/Command/ directory.
Hey,
I'm basically trying to implement https://github.com/J7mbo/twitter-api-php into the project in the form of a !twitter command. I'm just unsure how to include the required php (TwitterAPIExchange.php) file for it.
OK, where have you put the file in the directory structure?
Everywhere. I either get a duplicate class error or an autoloader error. Where should I put it?
I think you might be misunderstanding me. Where have you put the file "TwitterAPIExhange.php"?
If you put it in the same folder as the Autoloader.php and then when you want to use it call "new \TwitterAPIExchange($settings);".
The auto-loader will then kick in on the first load and load the file once.
The point of an auto-loader is to never have to use require/require_once/include or include_once yourself which tidies up the code and also avoids the multiply defined classes problems.
Oh, excellent. Thanks!
No problem. =)
I assume your issue is now resolved?
Hey, I'd like to use 'simple_html_dom.php' and it's not a class. I'm not having much luck guessing where to put him. Could you spoon-feed me? :)
Do you want to use that for a command?
Hey, I'm trying to add twitter functionality, but I'm having real trouble with autoloader.php trying to load my class or something?
PHP Fatal error: Uncaught exception 'Exception' with message 'File: "/home/steve/Desktop/bot/Classes/TwitterAPIExchange.php" not found.' in /home/steve/Desktop/bot/Classes/Autoloader.php:40
How can I do this?