Laravel And Twitter API as well as thujohn/twitter
Ad
So I followed his readme and I have done composer dump-autoload
a million times, but still I receive an error.
The code:
'providers' => [
...
Thujohn\Twitter\TwitterServiceProvider::class,
],
'aliases' => [
...
'Twitter' => Thujohn\Twitter\Facades\Twitter::class,
],
In my controller:
class HomeController extends Controller {
public function index() {
$tweets = Twitter::getUserTimeline([
'screen_name' => 'xxxxxxx',
'count' => 10,
'format' => 'json'
]);
dd($tweets);
return view('home');
}
public function about() {
return view('about');
}
}
But I get the error:
FatalErrorException in HomeController.php line 10:
Class 'App\Http\Controllers\Twitter' not found
Um ..... What?
Ad
Answer
Ad
You used non-namespaced name when you refered to Twitter class, so PHP is looking for the class in current namespace. Change that reference to \Twitter or add the following use statement:
use Twitter;
Ad
source: stackoverflow.com
Related Questions
Ad
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad