When I am making a API call to the http://localhost/lvl53/public/api/getSongs using Postman I get the following error.
FatalErrorException Doctrine\Common\Proxy\AbstractProxyFactory::getProxyDefinition(): Failed opening required.
Here are my routes web.php
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::group(['middleware' => ['web','auth']], function () {
Route::get('/song', 'SongController@index')->name('song');
Route::get('/addSong', 'SongController@addSong')->name('addNewSong');
Route::post('/registerSong', 'SongController@create')->name('registerSong');
});
Route::get('/home', 'HomeController@index')->name('home');
Here is api.php
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
Route::group(['middleware' => ['test']], function () {
Route::get('/getSongs', 'SongController@getSongs')->name('getSongs');
});
But if I add the API route getSongs to the Route::Group in web.php and after logging in make the call, then I am able to retrieve data.
Here's my SongController's getSongs method
public function getSongs(EntityManagerInterface $em)
{
$songs = $em->getRepository(SongEntity::class)->findAll();
$songList = [];
\Log::info(["Songs",$songs]);
foreach ($songs as $song){
$currentSong["artist"] = $song->getArtist();
$currentSong["title"] = $song->getTitle();
$currentSong["url"] = $song->getUrl();
array_push($songList, $currentSong);
}
return $songList;
/*return view('song.songs', ['songs' => Song::all()]);*/
}
In here when making the api call \Log doesn't create a log. How to retrieve data using the API? PS: When I looked into error msg they say I have do advance configurations on doctrine, it doesn't make sense. Any help is highly appreciated.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2vyEVVB
via IFTTT
Aucun commentaire:
Enregistrer un commentaire