NotFoundHttpException in RouteCollection.php line 161 Laravel - laravel-5

I am working with laravel 5. At first I defined a route as follows :
Route::get('/', function()
{
echo "entered here.";
}
);
When I access it with http://localhost:8383/onboardadmin3/public/ It works fine. But when I change the route as follows :
Route::get('/test', function()
{
echo "entered here.";
}
);
and try to access it with http://localhost:8383/onboardadmin3/public/test , I get the following error :
NotFoundHttpException in RouteCollection.php line 161:
I have read the stack overflow solutions from the following links but none helped :
Laravel 5.1 NotFoundHttpException in RouteCollection.php line 161:
NotFoundHttpException in RouteCollection.php line 161
https://stackoverflow.com/questions/37186650/in-laravel-5-notfoundhttpexception-in-routecollection-php-line-161
https://stackoverflow.com/questions/37186650/in-laravel-5-notfoundhttpexception-in-routecollection-php-line-161
How can I fix this ?

Related

Enabling email verification in laravel 5.2 - InvalidArgumentException in FileViewFinder.php

To enable email verification in laravel 5.2 , I found this error :
InvalidArgumentException in FileViewFinder.php line 137: View [**Activate account** <ahref="http:..localhost:8000.user.activation.3223338c9bef4f1ea34e4caff92fff2497c5c94b77e2665bfc975a9684df6e32">click here<.a>] **not found**.
I used
$link = route('user.activate', $token);
$message = sprintf('**Activate account** %s', $link, $link);
$this->mailer->send($message , [$message], function (Message $m) use ($user)
{
$m->to($user->email)->subject('Activation mail');
I used this route:
Route::get('user/activation/{token}', 'Auth\AuthController#activateUser')->name('user.activate');

Laravel Lumen ReflectionException

I already had a look at other post about how to fix the ReflectionException issue in laravel Lumen, using this:
$request = Illuminate\Http\Request::capture();
$app->run($request);
However it is not solving my problem. I have a controller called AccountController.php and placed in app/Http/Controllers/Account folder and here is the code:
<?php
namespace App\Http\Controllers\Account;
use App\Account;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class AccountController extends Controller {
public function createNewAccount(Request $request) {
$newAccount = Account::create($request->all());
return response()->json($newAccount);
}
}
And this is my route file placed in /routes/web.php:
<?php
$app->get('/hello', function () use ($app) {
return 'Hello World!';
});
$app->group(['prefix' => 'api/v1','namespace' => 'App\Http\Controllers\Account'], function($app)
{
$app->post('account','AccountController#createNewAccount');
});
When I test with Postman the get request which returns a simple 'Hello World' is working fine, but the POST call to api/v1/account/createNewAccount will always fail whatever I do:
ReflectionException in Container.php line 681:
Class App\Http\Controllers\App\Http\Controllers\Account\AccountController does not exist
in Container.php line 681
at ReflectionClass->__construct('App\Http\Controllers\App\Http\Controllers\Account\AccountController') in Container.php line 681
at Container->build('App\Http\Controllers\App\Http\Controllers\Account\AccountController') in Container.php line 565
at Container->make('App\Http\Controllers\App\Http\Controllers\Account\AccountController') in Application.php line 208
at Application->make('App\Http\Controllers\App\Http\Controllers\Account\AccountController') in RoutesRequests.php line 677
at Application->callControllerAction(array(true, array('uses' => 'App\Http\Controllers\App\Http\Controllers\Account\AccountController#createNewAccount'), array())) in RoutesRequests.php line 644
at Application->callActionOnArrayBasedRoute(array(true, array('uses' => 'App\Http\Controllers\App\Http\Controllers\Account\AccountController#createNewAccount'), array())) in RoutesRequests.php line 629
at Application->handleFoundRoute(array(true, array('uses' => 'App\Http\Controllers\App\Http\Controllers\Account\AccountController#createNewAccount'), array())) in RoutesRequests.php line 528
at Application->Laravel\Lumen\Concerns{closure}() in RoutesRequests.php line 782
at Application->sendThroughPipeline(array(), object(Closure)) in RoutesRequests.php line 534
at Application->dispatch(object(Request)) in RoutesRequests.php line 475
at Application->run(object(Request)) in index.php line 29
I am using "laravel/lumen-framework": "5.4.*".
There is no reply to this particular issue, I decided to build my API with Dingo API: https://github.com/dingo/api It is a good package to build API with Laravel/lumen. They created their own routing system and things are going much better since.

laravel guzzlehttp - Server Exception in RequestException.php

I am getting ServerException in RequestException.php line 107 when I make POST request to my API. I get following error -
Server error: POST http://10.10.1.40:3000/auth/register resulted in a 500 Internal Server Error response:
{"statusCode":500,"errorMessage":"[object Object]"}.
I tried sending post request from REST Client and it works.
Following is the trace
in RequestException.php line 107 at RequestException::create(object(Request), object(Response)) in Middleware.php line 65
at Middleware::GuzzleHttp\{closure}(object(Response)) in Promise.php line 199
at Promise::callHandler('1', object(Response), array(object(Promise), object(Closure), null)) in Promise.php line 152
at Promise::GuzzleHttp\Promise\{closure}() in TaskQueue.php line 60
at TaskQueue->run(true) in Promise.php line 240
at Client->request('POST', 'http://10.10.1.40:3000/auth/register', array('body' => '{"firstName":"abc","lastName":"ab"}')) in RegisterController.php line 30
at RegisterController->postRegisterForm(object(Request))
Following is my controller code
class RegisterController extends Controller{
public function postRegisterForm(Request $request){
$jsonData = json_encode($_POST);
$client = new Client();
$res = $client->request('POST','10.10.1.40:3000/auth/register', ['body' => $jsonData]);
echo $res->getStatusCode();
echo $res->getBody();
}
}
Any suggestions?
You are right #ShaunBramley. I missed out sending the content type header in request. Adding following code works -
$headers = ['Content-Type' => 'application/json'];
$res = $client->request('POST', 'http://10.10.1.40:3000/auth/register', ['headers'=>$headers,'body' => $jsonData]);

Socialite Library throwing error curl_reset() undefined in laravel 5

I am using socialite package with my laravel 5 project. I am hosting my site in hostgator. I have checked thrice that my php version in hostgator is 5.5.22 .
But still i am getting this error.
FatalErrorException in CurlFactory.php line 69:
Call to undefined function GuzzleHttp\Handler\curl_reset()
in CurlFactory.php line 69
I have tried Facebook as well as Google plus login using socialite but in both cases when redirects to my controller/function it throws this error.
Please help me. What can be possible errors
My Auth controller functions are
public function getFacebookLogin(){
return Socialite::driver('facebook')->redirect();
}
public function getHandleFbLogin(){
//echo "hey";
$user = Socialite::driver('facebook')->user();
print_r($user);
}
public function getGoogleLogin(){
return Socialite::driver('google')->redirect();
}
public function getHandleGpLogin(){
echo "hey";
$user = Socialite::driver('google')->user();
print_r($user);
}
I am very new to Stackoverflow. I also got stucked in this, so I did the following :-
Go to
/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php
line no. 69 and replace
curl_reset($resource);
with
curl_setopt($resource, CURLOPT_HTTPGET, 1);
curl_setopt($resource, CURLOPT_POST, false);

Laravel error ; Controller method not found

I have in routes.php :
Route::any('project/(:num)', array('as' =>'pr', 'uses'=>'ProjectController#getIndex'));
Route::any('project/(:num)/(:any)', array('as' =>'pr', 'uses'=>'ProjectController#(:2)'));
and I am getting an error : Controller method not found
What is the problem I have getIndex
Thanks

Resources