Using Corcel with Laravel

Natalie Rosman
1 reply
I am attempting to use Corcel with Laravel and using instructions from Adeva: https://adevait.com/laravel/usin... But, am having issues. I am pretty new to Laravel, so I am certain it's something I am doing, but this is a learning experience for me and looking for those who may be able to point me in the right direction. The problem I am having is when I get to the portion where it says "So, now you can fetch database data:" Code: $posts = App\Post::all(); // using the 'wordpress' connection $posts = Corcel\Post::all(); // using the 'default' Laravel connection I've tried both of those, and get the errors each time. Code: Class 'myNameSpace\Http\Controllers\App\Post' not found That is when I use the App\Post version. Code: Class 'Corcel\Post\Post' not found That is when I use the Corcel\Post version. I also have this in my controller and the Post model class: Code: use Corcel\Post as Corcel; Is there something that I am missing? Thank you!

Replies

Nitin Mahajan
The error message suggests that there might be a namespace conflict. Make sure you're using the correct namespace. In your controller, try using either: use App\Post; or use Corcel\Post as CorcelPost; Also, make sure that you've run 'composer dump-autoload' after installing Corcel. Let me know if error message still persist. If you want to know more about Laravel 10 :https://eluminoustechnologies.co...