I get an error when setting Laravel in maintenance mode
HttpException in CheckForMaintenanceMode.php line 39:
in CheckForMaintenanceMode.php line 39
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
at Pipeline->then(object(Closure)) in Kernel.php line 115
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 84
at Kernel->handle(object(Request)) in index.php line 53
This is expected behaviour. You need to catch that exception and respond to it however you see fit.
More info:
http://laravel.com/docs/master/installation#maintenance-mode
Laravel will look for the following file and display it if found:
resources/views/errors/503.blade.php
Related
I bought a script (radio web portal) which use Laravel framework but I have the following error :
FatalThrowableError in Encrypter.php line 73:
Call to undefined function openssl_encrypt()
in Encrypter.php line 73
at Encrypter->encrypt('msDJBCdI0hnJ95VuR6dnHo4jmZwo13AVVcb2FNEq') in
EncryptCookies.php line 131
at EncryptCookies->encrypt(object(Response)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php
line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php
line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php
line 104
at Pipeline->then(object(Closure)) in Router.php line 644
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php
line 618
at Router->dispatchToRoute(object(Request)) in Router.php line 596
at Router->dispatch(object(Request)) in Kernel.php line 267
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in
Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Debugbar.php
line 51
at Debugbar->handle(object(Request), object(Closure)) in Pipeline.php line
137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php
line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in
CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in
Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php
line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php
line 104
at Pipeline->then(object(Closure)) in Kernel.php line 149
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
at Kernel->handle(object(Request)) in index.php line 53
in Encrypter.php line 73
at Encrypter->encrypt('a:5:
{s:6:"_token";s:40:"msDJBCdI0hnJ95VuR6dnHo4jmZwo13AVVcb2FNEq";s:9:"_previous";a:1:{s:3:"url";s:47:"http://localhost/sito2/radiowebportal/index.php";}s:22:"PHPDEBUGBAR_STACK_DATA";a:0:{}s:9:"_sf2_meta";a:3:{s:1:"u";i:1526184338;s:1:"c";i:1526184338;s:1:"l";s:1:"0";}s:6:"_flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}}') in EncryptedStore.php line 57
at EncryptedStore->prepareForStorage('a:5:{s:6:"_token";s:40:"msDJBCdI0hnJ95VuR6dnHo4jmZwo13AVVcb2FNEq";s:9:"_previous";a:1:{s:3:"url";s:47:"http://localhost/sito2/radiowebportal/index.php";}s:22:"PHPDEBUGBAR_STACK_DATA";a:0:{}s:9:"_sf2_meta";a:3:{s:1:"u";i:1526184338;s:1:"c";i:1526184338;s:1:"l";s:1:"0";}s:6:"_flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}}') in Store.php line 262
at Store->save() in StartSession.php line 88
at StartSession->terminate(object(Request), object(Response)) in Kernel.php line 176
at Kernel->terminate(object(Request), object(Response)) in index.php line 58
First make sure you installed the openssl extension (spotted by deceze), then:
Go to your php.ini file
Remove the semicolon before extension=php_openssl.dll
Restart your Apache
I'm expecting this to be the problem.
I use Route::delete() methods in my routes file. Until I moved the app to the new server I had no issues by using this method, but now I get the MethodNotAllowedHttpException. I used the app for about 6 months without any problems. But now I get this on every delete process. Of course when I change the method to post and add a hidden var _method it works. But I wonder what (setting) could cause this on the new server. Any ideas?
The exception detail:
MethodNotAllowedHttpException in RouteCollection.php line 218:
in RouteCollection.php line 218
at RouteCollection->methodNotAllowed(array('DELETE')) in RouteCollection.php line 205
at RouteCollection->getRouteForMethods(object(Request), array('DELETE')) in RouteCollection.php line 158
at RouteCollection->match(object(Request)) in Router.php line 821
at Router->findRoute(object(Request)) in Router.php line 691
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 5
MethodNotAllowedHttpException means the route is not found for your http request.
The methodNotAllowed exception indicates that a route doesn't exist for the HTTP method you are requesting.
Route::delete Example:
Route::delete('empresas/eliminar/{id}', [
'as' => 'companiesDelete',
'uses' => 'CompaniesController#delete'
]);
I have a problem with my routes in Laravel.
When I use the following route:
Route::resource('user', 'PostsController');
The methods PUT and DELETE work fine with the functions destroy and update in my controller, but when I use the following route:
Route::delete('{$id}', function($id){
return "Remover o usuário ".$id;
});
and
Route::put('{$id}', function($id){
return "Editar o usuário ".$id;
});
I have the following error:
NotFoundHttpException in RouteCollection.php line 161:
in RouteCollection.php line 161
at RouteCollection->match(object(Request)) in Router.php line 780
at Router->findRoute(object(Request)) in Router.php line 610
at Router->dispatchToRoute(object(Request)) in Router.php line 596
at Router->dispatch(object(Request)) in Kernel.php line 267
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request)) in Pipeline.php line 53
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in HandleCors.php line 42
at HandleCors->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 46
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 137
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Pipeline.php line 33
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in Pipeline.php line 104
at Pipeline->then(object(Closure)) in Kernel.php line 149
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 116
at Kernel->handle(object(Request)) in index.php line 56
at require_once('C:\xampp\htdocs\apiRest\public\index.php') in server.php line 21
Bellow follow the image to more details how I send the request
Request
I'm using the Postsman to send the request.
Please, can anyone help me??
In Laravel route parameters are defined without a $ like {id} instead of {$id}. See the docs for more info.
So in your case:
Route::delete('{id}', function($id){
return "Remover o usuário ".$id;
});
and:
Route::put('{id}', function($id){
return "Editar o usuário ".$id;
});
I am a beginner with Laravel (5.2) and so if this is obvious I apolgise. I have an entry in a Post controller to delete an entry which is passed:
public function getDeletePost( $post_id )
{
$post = Post::where('id', $post_id)->first();
$post->delete();
$message = "successfully deleted";
return redirect()->route('dashboard')->with( ['message'=> $message] );
}
which is called from a function in the routes file:
Route::get('/delete-post/{post_id}',
[ 'uses'=> 'PostController#getDeletePost',
'as' => 'post.delete' ]);
The route is called from a page:
delete
The page is showing the correct URL (http://localhost:8000/post-delete/5) but I am getting the following error and cannot seem to get around it:
Sorry, the page you are looking for could not be found.
1/1 NotFoundHttpException in RouteCollection.php line 161:
in RouteCollection.php line 161
at RouteCollection->match(object(Request)) in Router.php line 823
at Router->findRoute(object(Request)) in Router.php line 691
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
at require_once('D:\websites\__laravel\socialnetwork\public\index.php') in server.php line 21
Yes a typo! I am suitably humbled!
I'm trying the suggestions for getting validation working on a new Laravel 5.2 install on Bitnami WAMP and having no luck. I have tried both suggestions that are given at Laravel 5.2 $errors not appearing in Blade among other places with the following errors returned from pages that have not even begun using validation.
When I try putting my working route (app/http/routes.php) on Route::group(['middleware' => ['web']], function () {... etc. as follows:
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
];
I get the following error messegaes:
+ RuntimeException in Request.php line 852: Session store not set on request.
+ in Request.php line 852 at Request->session()
+ in ShareErrorsFromSession.php line 42
+ 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)) at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
+ 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 124
+ 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
When I try moving my protected $middlewareGroups web (app/Http/Kernel.php) on protected $middleware = [], as follows:
Route::group(['middleware' => 'web'], function() {
Route::resource('country', 'Region\CountryController');
});
I get the error messages:
+ RuntimeException in EncryptionServiceProvider.php line 31: No supported encrypter found. The cipher and / or key length are invalid.
+ in EncryptionServiceProvider.php line 31
+ at EncryptionServiceProvider->Illuminate\Encryption{closure}(object(Application), array()) in Container.php line 735
+ at Container->build(object(Closure), array()) in Container.php line 633 at Container->make('encrypter', array()) in Application.php line 674
+ at Application->make('Illuminate\Contracts\Encryption\Encrypter') in Container.php line 853
+ at Container->resolveClass(object(ReflectionParameter)) in Container.php line 808
+ at Container->getDependencies(array(object(ReflectionParameter)), array()) in Container.php line 779
+ at Container->build('App\Http\Middleware\EncryptCookies', array()) in Container.php line 633
+ at Container->make('App\Http\Middleware\EncryptCookies', array()) in Application.php line 674
+ at Application->make('App\Http\Middleware\EncryptCookies') in Pipeline.php line 123
+ 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 124
+ 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
These errors come up on a page that is not even asking for validation yet.
When I attempt to get $errors on a blade template that is redirected to after an update in the store method, $errors is not defined either.
Any help is welcome as I have been trying to solve this for several days now in a new Laravel 5.2 installation.
Thank you
(Posting it here as a formal answer)
The second way you mention is more convenient, applying middlewares (or middleware groups, as web is) in your routes definition.
The web group includes middlewares related to session and encrypting. Laravel uses the value of APP_KEY to encrypt all session data, and form inputs and validation errors are stored in the session.
At some point during the session access, Laravel tries to create en Encrypter object, which fails if the application key is not 32 characters long. I just found that reading the source code, but you just need to know that when you do the initial configuration of your application, your .env file should have a 32-long random string as APP_KEY. The Artisan command key:generate does that for you.