I'm new to laravel4.2 trying to create a RESTFUL API, but getting error when I'm trying to hit URL{localhost/TPM/public/api/books} in postman.
what would be the URL for this??
Controller:
Router:
Try with return Response::json(['result' => true]); in your index method.
In addition, you can check the logs file for clues of what's going on in storage/logs/laravel.log.
I think in Laravel 4.2 you needed to perform a composer dump-autoload if created new classes but not sure.
Related
I added Laravel lumen in full stack Laravel framework but I got API routing issue like below. Please help me to solve below problem.
I added bootstrap/api.php for use lumen in laravel framework. I configure lumen like below in Laravel framework.
bootstarp/api.php
$app->register(App\Providers\AppServiceProvider::class);
App\Providers\AppServiceProvider
$this->app->singleton('Illuminate\Contracts\Routing\ResponseFactory', function ($app) {
return new ResponseFactory(
$app['Illuminate\Contracts\View\Factory'],
$app['Illuminate\Routing\Redirector']);
});
After adding above code in AppServiceProvider, I get this error:
Target [Illuminate\Routing\RouteCollectionInterface] is not instantiable while building [Illuminate\Routing\Redirector, Illuminate\Routing\UrlGenerator]
Thank you in advance.
I have a running app written on Laravel 5.7. I tried to change the record in composer.json to match "5.8.*" and ran composer update. On my local (win10/WAMP) machine it went fine, but on the staging server (Debian 9/nginx) the update command changed the vendor contents and failed at the end.
Since then anything I do with the app on the server I get this error and I can't find any information anywhere.
Call to undefined method Illuminate\Routing\RouteFileRegistrar::get()
And this is the line that fails:
$this->get('login', 'Auth\LoginController#showLoginForm')->name('login');
Thanks in advance!
remove "$this" from your routes and use "Route::"
It is a problem with the routes. Mainly, you get this problem when you are using routes with resource or resources. Make sure you do not have any problem in routes by using the command:
#php artisan route:list
If you are getting any problem while route listing please fix it.
I solved this problem in Laravel 5.8 by fixing routes.
Hope this will help.
Trying to use Postman to test my app.
Got an access_token and id_token by posting to /oauth/ro using a test use I created on Auth0's dashboard.
Now in the seed project there's this route /api/protected and I'm trying to do a GET request on it using Postman.
This guide says just add this header authorization": "Bearer YOUR_ID_TOKEN_HERE"
I did but I always get Unauthorized User
tried to tinker and found out it's looking for config('laravel-auth0.secret_base64_encoded')
tried to use this and manually execute the $verifier->verifyAndDecode($encUser);
but before that, i set secret_base64_encoded to false and it worked!
EDIT: The seed project on their quickstart is OLD find the new one
Using laravel 5.1 this works fine on an ajax call:
$conn = Session::get('conn') or abort(500, 'No conn detected')
The variable is set and if the session key is not detected the error 500 is fired.
But on a brand new install of Laravel 5.4 the same code doesn't work, I can test it fine using a normal GET request but if I using ajax I always get the 500 error. I'm using the 'file' session session driver in both cases.
Did something change from Laravel 5.1 to 5.4 about session access on ajax call? I couldn't find any info about it.
Thanks!
In file app/Http/Kernel.php there is array $middlewareGroups and there \Illuminate\Session\Middleware\AuthenticateSession::class is commented. Uncomment this line and try again.
I've picked up a project that was developed using Laravel 4.2. I've deployed it to my testing server (a Bitnami LAMP) and everything works as it's supposed to. HOWEVER, new routes that I create don't work, getting the error NotFoundHttpException.
I've gone through a few recommendations, but nothing has been successful thus far.
Any thoughts or ideas??
Thanks!
--
Just to clarify, any NEW route throws the same Not Found error. Even the simplest one like:
Route::get('test', function(){
return "This is a test";
});
It seems like Laravel is only serving an old version of the Routes.php, is this even possible???
Resolved this by recreating the project using Laravel 5 instead.