I was just importing this Lumen project from my local machine to an Ubuntu 14.04 VirtualBox. Both exact same code.
I've tried composer update, composer install. Also from other kind of simillar questions I've added this to the composer.json
"autoload": {
"psr-4": {
"App\\": "app/"
},
"files": [
"app/Library/recaptchalib.php",
"app/Library/function.php"
],
"classmap": [
"database/"
]
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php" //added this
]
},
This is the full error log
ReflectionException in Container.php line 741:
Class injection does not exist
in /var/www/lumen_app_test/vendor/illuminate/container/Container.php line 741
at ReflectionClass->__construct('injection') in Container.php line 741
at Container->build('injection', array()) in Container.php line 631
at Container->make('injection', array()) in Application.php line 447
at Application->make('injection') in Pipeline.php line 123
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Application.php line 1439
at Application->sendThroughPipeline(array('injection', 'App\Http\Middleware\LanguageMiddleware', 'App\Http\Middleware\AssetVersionMiddleware'), object(Closure)) in Application.php line 1284
at Application->handleFoundRoute(array(true, array('as' => 'home', 'uses' => 'App\Http\Controllers\HomeController#index', 'middleware' => array('injection', 'language', 'asset_version')), array())) in Application.php line 1207
at Application->Laravel\Lumen\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Application.php line 1439
at Application->sendThroughPipeline(array('Illuminate\Cookie\Middleware\EncryptCookies', 'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse', 'Illuminate\Session\Middleware\StartSession', 'Illuminate\View\Middleware\ShareErrorsFromSession'), object(Closure)) in Application.php line 1213
at Application->dispatch(object(Request)) in Application.php line 1153
at Application->run(object(Request)) in index.php line 29
The thing that made me confuse it that this app runs with no problem in my other machine.
Have you applied a middleware called injection anywhere? Or is it in the constructor of your HomeController? Looks like the container is looking for the definition of that middleware but can't find it (it would usually go in app/Http/Kernel.php.
If all else fails, delete /vendor and then run composer update to get a fresh copy of everything.
Related
Version:Laravel 5.2
issue:
BadMethodCallException in Validator.php line 3295:
Method [validateNickName] does not exist.
in Validator.php line 3295
at Validator->__call('validateNickName', array('nick_name', 'chenmin', array(), object(Validator))) in Validator.php line 485
at Validator->validateNickName('nick_name', 'chenmin', array(), object(Validator)) in Validator.php line 485
at Validator->validate('nick_name', 'nick_name') in Validator.php line 425
at Validator->passes() in Validator.php line 450
at Validator->fails() in ValidatesRequests.php line 53
at Controller->validate(object(Request), array('nick_name' => 'required|nick_name|unique:users|max:30', 'cellphone' => 'required|cellphone|unique:users|numeric|phone_number|size:11', 'captcha' => 'required|numeric|size:6', 'password' => 'required|min:6|max:30')) in UserController.php line 19
at UserController->postSignUp(object(Request))
at call_user_func_array(array(object(UserController), 'postSignUp'), array(object(Request))) in Controller.php line 80
at Controller->callAction('postSignUp', array(object(Request))) in ControllerDispatcher.php line 146
at ControllerDispatcher->call(object(UserController), object(Route), 'postSignUp') in ControllerDispatcher.php line 94
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96
at ControllerDispatcher->callWithinStack(object(UserController), object(Route), object(Request), 'postSignUp') in ControllerDispatcher.php line 54
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\UserController', 'postSignUp') in Route.php line 174
at Route->runController(object(Request)) in Route.php line 140
at Route->run(object(Request)) in Router.php line 724
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 64
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 64
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 726
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 699
at Router->dispatchToRoute(object(Request)) in Router.php line 675
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 54
source code:
namespace App\Http\Controllers;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
class UserController extends Controller
{
public function postSignUp(Request $request)
{
$this->validate($request, [
'nick_name' => 'required|nick_name|unique:users|max:30',
'cellphone' => 'required|cellphone|unique:users|numeric|phone_number|size:11',
'captcha' => 'required|numeric|size:6',
'password' => 'required|min:6|max:30'
]);
.......
when I test the input from ,met a weird issue:BadMethodCallException in Validator.php line 3295:Method [validateNickName] does not exist.
who can help me to solve it ?thanks a lot!
nickn_name and cell_phone and phone_number are not validation rules?
so you cannot put them in the rule string. Your validation rules should looks as follow:
$this->validate($request, [
'nick_name' => 'required|unique:users|max:30',
'cellphone' => 'required|unique:users|numeric|size:11',
'captcha' => 'required|numeric|size:6',
'password' => 'required|min:6|max:30'
]);
I think is because you are using snake_case for nick_name, and somehow the validator thinks that you are calling a custom validation rule called nickName (bits of Laravel always convert snake_case to camelCase when helpers are called)... why would you call nickname nick_name ? In english I think is just one word...
I tried to deploy my first Laravel project on Heroku. It's a small project, so I'm using SQLite as my database. After deploying the project using git push heroku master, and clicking on one of the links that retrieves data from the database to display an index, I am getting the following error:
PDOException in Connector.php line 55: could not find driver
in Connector.php line 55
at PDO->__construct('sqlite:/app/database/database.sqlite', null, null, array('0', '2', '0', false, false)) in Connector.php line 55
at Connector->createConnection('sqlite:/app/database/database.sqlite', array('driver' => 'sqlite', 'database' => '/app/database/database.sqlite', 'prefix' => '', 'name' => 'sqlite'), array('0', '2', '0', false, false)) in SQLiteConnector.php line 37
at SQLiteConnector->connect(array('driver' => 'sqlite', 'database' => '/app/database/database.sqlite', 'prefix' => '', 'name' => 'sqlite')) in ConnectionFactory.php line 61
at ConnectionFactory->Illuminate\Database\Connectors\{closure}()
at call_user_func(object(Closure)) in Connection.php line 875
at Connection->getPdo() in Connection.php line 743
at Connection->reconnectIfMissingConnection() in Connection.php line 628
at Connection->run('select * from "certificates" order by "updated_at" desc', array(), object(Closure)) in Connection.php line 342
at Connection->select('select * from "certificates" order by "updated_at" desc', array(), true) in Builder.php line 1562
at Builder->runSelect() in Builder.php line 1548
at Builder->get(array('*')) in Builder.php line 610
at Builder->getModels(array('*')) in Builder.php line 316
at Builder->get() in CertificatesController.php line 25
at CertificatesController->index()
at call_user_func_array(array(object(CertificatesController), 'index'), array()) in Controller.php line 80
at Controller->callAction('index', array()) in ControllerDispatcher.php line 146
at ControllerDispatcher->call(object(CertificatesController), object(Route), 'index') in ControllerDispatcher.php line 94
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96
at ControllerDispatcher->callWithinStack(object(CertificatesController), object(Route), object(Request), 'index') in ControllerDispatcher.php line 54
at ControllerDispatcher->dispatch(object(Route), object(Request), 'app\Http\Controllers\CertificatesController', 'index') in Route.php line 174
at Route->runController(object(Request)) in Route.php line 140
at Route->run(object(Request)) in Router.php line 724
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 64
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Router.php line 726
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 699
at Router->dispatchToRoute(object(Request)) in Router.php line 675
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 136
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 53
Anyone knows how I may be able to resolve this problem? Many thanks in advance! :)
I've also encountered this on Heroku.
I added:
{
"require": {
"ext-pdo_sqlite": "*"
}
}
Sqlite is setup as a shared extension on Heroku, but has to be enabled through composer.json i believe.
Try adding:
{
"require": {
"sqlite3": "*"
}
}
To your composer.json file.
I have just started learning laravel.
I am using laravel 5.2.29
I am getting error when running the code:
Whoops, looks like something went wrong.
BadMethodCallException in Controller.php line 107:
Method [validate] does not exist.
Here is the error line displayed:
in Controller.php line 107
2.at Controller->__call('validate', array(object(Request), array('action' => 'required', 'name' => 'required'))) in NiceActionController.php line 31
3.at NiceActionController->validate(object(Request), array('action' => 'required', 'name' => 'required')) in NiceActionController.php line 31
4.at NiceActionController->postNiceAction(object(Request))
5.at call_user_func_array(array(object(NiceActionController), 'postNiceAction'), array(object(Request))) in Controller.php line 80
6.at Controller->callAction('postNiceAction', array(object(Request))) in ControllerDispatcher.php line 146
7.at ControllerDispatcher->call(object(NiceActionController), object(Route), 'postNiceAction') in ControllerDispatcher.php line 94
8.at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
9.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
10.at Pipeline->Illuminate\Routing\{closure}(object(Request))
11.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
12.at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96
13.at ControllerDispatcher->callWithinStack(object(NiceActionController), object(Route), object(Request), 'postNiceAction') in ControllerDispatcher.php line 54
14.at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\NiceActionController', 'postNiceAction') in Route.php line 174
15.at Route->runController(object(Request)) in Route.php line 140
16.at Route->run(object(Request)) in Router.php line 724
17.at Router->Illuminate\Routing\{closure}(object(Request))
18.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
19.at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 64
20.at VerifyCsrfToken->handle(object(Request), object(Closure))
21.at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
22.at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
23.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
24.at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
25.at ShareErrorsFromSession->handle(object(Request), object(Closure))
26.at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
27.at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
28.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
29.at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 62
30.at StartSession->handle(object(Request), object(Closure))
31.at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
32.at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
33.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
34.at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
35.at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
36.at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
37.at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
38.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
39.at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
40.at EncryptCookies->handle(object(Request), object(Closure))
41.at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
42.at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
43.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
44.at Pipeline->Illuminate\Routing\{closure}(object(Request)) in VerifyCsrfToken.php line 64
45.at VerifyCsrfToken->handle(object(Request), object(Closure))
46.at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
47.at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
48.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
49.at Pipeline->Illuminate\Routing\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
50.at ShareErrorsFromSession->handle(object(Request), object(Closure))
51.at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
52.at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
53.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
54.at Pipeline->Illuminate\Routing\{closure}(object(Request)) in StartSession.php line 62
55.at StartSession->handle(object(Request), object(Closure))
56.at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
57.at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
58.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
59.at Pipeline->Illuminate\Routing\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
60.at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
61.at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
62.at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
63.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
64.at Pipeline->Illuminate\Routing\{closure}(object(Request)) in EncryptCookies.php line 59
65.at EncryptCookies->handle(object(Request), object(Closure))
66.at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
67.at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
68.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
69.at Pipeline->Illuminate\Routing\{closure}(object(Request))
70.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
71.at Pipeline->then(object(Closure)) in Router.php line 726
72.at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 699
73.at Router->dispatchToRoute(object(Request)) in Router.php line 675
74.at Router->dispatch(object(Request)) in Kernel.php line 246
75.at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
76.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
77.at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
78.at CheckForMaintenanceMode->handle(object(Request), object(Closure))
79.at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
80.at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
81.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
82.at Pipeline->Illuminate\Routing\{closure}(object(Request))
83.at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
84.at Pipeline->then(object(Closure)) in Kernel.php line 132
85.at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
86.at Kernel->handle(object(Request)) in index.php line 54
My route code:
<?php
Route::group(['middleware' => ['web']], function(){
Route::get('/', function () {
return view('home');
})->name('home');
Route::group(['prefix'=>'do'], function(){
Route::get('/{action}/{name?}', [
'uses' => 'NiceActionController#getNiceAction',
'as' => 'niceaction' //router name same as ->name('routername')
]);
Route::post('/', [
'uses' => 'NiceActionController#postNiceAction',
'as' => 'benice'
]);
});
});
My Controller code is given below:
<?php
namespace App\Http\Controllers;
use Illuminate\Routing\Controller;
use \Illuminate\Http\Request;
class NiceActionController extends Controller
{
public function getNiceAction($action, $name=null)
{
return view('actions.'.$action, ['name' => $name]);
}
public function postNiceAction(Request $request)
{
$this->validate($request, [
'action' => 'required',
'name' =>'required'
]);
return view('actions.nice', ['action'=>$request['action'],'name'=>$this->transformName($request['name'])]);
}
private function transformName($name)
{
$prefix='KING';
return $prefix.strtoupper($name);
}
}
My base main controller "controller" has following code:
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesResources;
class Controller extends BaseController
{
use AuthorizesRequests, AuthorizesResources, DispatchesJobs, ValidatesRequests;
}
Am i missing anything????
You need to extend the App\Http\Controllers\Controller class which uses the necessary ValidatesRequests trait that implements the required validate method.
So in your NiceActionController class just remove this line:
use Illuminate\Routing\Controller;
That way this line:
class NiceActionController extends Controller
Will extend the proper Controller class from the same namespace (more precisely App\Http\Controllers\Controller), which includes the necessary traits and which already extends that Illuminate\Routing\Controller class (aliased as BaseController).
To display errors, simply remove the line below and the closing )}
Route::group(['middleware' => ['web']], function(){
As of 5.2, routes.php is by default already called in the context of a ['middleware'=>'web'] by RouteServiceProvider.
// But in routes.php default generation of auth routes, the Route::group call is still happening by default - so if you delete that Route::group
// declaration from routes.php the application then correctly shows errors.
I'm getting this error, while trying to access a page that I've added in my routes..
ex. laravel.com/about-us
here's a sample of my routes code.
I was asked to do the routes in config.php
'about-us' => [
'controller' => 'page',
'method' => 'about',
'enable' => true
],
and a method like this.
public function about() {
return view($this->getViewPrefix() . '::page.about');
}
The ful error:
NotFoundHttpException in Application.php line 879:
in Application.php line 879
at Application->abort('404', '', array()) in helpers.php line 21
at abort('404') in helpers.php line 45
at cd_abort('404') in routes.php line 93
at ServiceProvider->{closure}('about-us')
at call_user_func_array(object(Closure), array('param1' => 'about-us')) in Route.php line 155
at Route->runCallable(object(Request)) in Route.php line 130
at Route->run(object(Request)) in Router.php line 704
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 706
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 671
at Router->dispatchToRoute(object(Request)) in Router.php line 631
at Router->dispatch(object(Request)) in Kernel.php line 236
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 50
at VerifyCsrfToken->handle(object(Request), object(Closure))
at call_user_func_array(array(object(VerifyCsrfToken), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 122
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
at Kernel->handle(object(Request)) in index.php line 54
I personally don't think it's how I did these things, because one of my colleagues got two of these pages to work, (they only have two) ..
does this have to do with my installation, or maybe my OS lol.?
I don't think you can write routes in config file. You have to write your routes in this file app/Http/routes.php Write these lines
Route::get('about-us', [
'as' => 'aboutUs', 'uses' => 'PagesController#about'
]);
Write your controller's name instead of PagesController. You have to make your controller inside this folder app/Http/Controllers
Laravel has the routes.php file to contain all the application related routing. This file will be autoloaded when the application runs.
Therefore, include your routing in this file for best practice.
A "get" routing will be like:
Route::get('/about-us', [ 'as' => 'about', 'uses' => 'PagesController#about']);
Similarly a 'post' routing:
Route::post('/about-us', [ 'as' => 'about', 'uses' => 'PagesController#about']);
Remember to name the controller file as "PagesController". Its the proper naming convention.
"#about" is the method in the PagesController that will handle the logic.
For better understanding: Laravel Routing
Hope this is helpful.
I'm pretty new to using Swagger. Since my project is with Laravel, I use Swaggerevel to document my API. During I tried to generate as follows,
./vendor/bin/swagger app/ -o storage/docs/api-docs.json
It shows that
[INFO] Required #SWG\Info() not found
get /api/resource.json
-----------------------
1 operations documented
-----------------------
Written to /home/admin/api/gevme-api/storage/docs/api-docs.json
When I tried to access, It localhost:8000/docs, It properly show json api which I generated. But when I tried to access localhost:8000/api-docs, the same error message show again.
ErrorException in Logger.php line 38:
Required #SWG\Info() not found
in Logger.php line 38
at HandleExceptions->handleError('1024', 'Required #SWG\Info() not found', '/home/admin/api/gevme-api/vendor/zircote/swagger-php/src/Logger.php', '38', array('entry' => 'Required #SWG\Info() not found', 'type' => '1024'))
at trigger_error('Required #SWG\Info() not found', '1024') in Logger.php line 38
at Logger->Swagger\{closure}('Required #SWG\Info() not found', '1024')
at call_user_func(object(Closure), 'Required #SWG\Info() not found', '1024') in Logger.php line 68
at Logger::notice('Required #SWG\Info() not found') in AbstractAnnotation.php line 365
at AbstractAnnotation->validate() in Analysis.php line 284
at Analysis->validate() in functions.php line 46
at Swagger\scan('/home/admin/api/gevme-api/modules/Api', array('exclude' => array('/home/admin/api/gevme-api/storage', '/home/admin/api/gevme-api/tests', '/home/admin/api/gevme-api/resources/views', '/home/admin/api/gevme-api/config', '/home/admin/api/gevme-api/vendor'))) in routes.php line 39
at SwaggervelServiceProvider->{closure}()
at call_user_func_array(object(Closure), array()) in Route.php line 155
at Route->runCallable(object(Request)) in Route.php line 130
at Route->run(object(Request)) in Router.php line 704
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Router.php line 706
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 671
at Router->dispatchToRoute(object(Request)) in Router.php line 631
at Router->dispatch(object(Request)) in Kernel.php line 236
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in OAuthExceptionHandlerMiddleware.php line 36
at OAuthExceptionHandlerMiddleware->handle(object(Request), object(Closure))
at call_user_func_array(array(object(OAuthExceptionHandlerMiddleware), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Kernel.php line 122
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
at Kernel->handle(object(Request)) in index.php line 54
at require_once('/home/admin/api/gevme-api/public/index.php') in server.php line 21
The problem is - you're missing the #SWG\Info block.
It's a block which tells swagger some most common information about your API.
I usually put this in a separate controller which is rendering swagger JSON.
Here's an example:
/**
* #SWG\Swagger(
* schemes={"http","https"},
* host="api.host.com",
* basePath="/",
* #SWG\Info(
* version="1.0.0",
* title="This is my website cool API",
* description="Api description...",
* termsOfService="",
* #SWG\Contact(
* email="contact#mysite.com"
* ),
* #SWG\License(
* name="Private License",
* url="URL to the license"
* )
* ),
* #SWG\ExternalDocumentation(
* description="Find out more about my website",
* url="http..."
* )
* )
*/
class SwaggerController extends...
If this happens to you, and you have the Swagger definition in the controller etc but still aren't seeing the comments make sure you don't have the following settings in your opcache configuration:
opcache.save_comments=1
opcache.load_comments=1
The settings above remove and not-load the docblox needed for swagger to create the documentation.
For Laravel 5.6 I launched
composer require darkaonline/l5-swagger:5.6
and quietly installed version 5.6.0 (which was linked to zircote/swagger-php version TWO), and I got subj error having #OA\Info block in Controller even.
When I runned
composer require darkaonline/l5-swagger:5.6.9
and increased version of zircote/swagger-php to
composer require zircote/swagger-php:3.0.2
my problem was solved