Laravel 5.1 - Session store not set on request - php

I was trying to upgrade a Laravel 4.1 application to 5.1 on WAMP, and got this error:
RuntimeException in Request.php line 775: Session store not set on
request.
in
D:\wamp\www\laravel-5.1\vendor\laravel\framework\src\Illuminate\Http\Request.php
line 775 at Request->session() in
D:\wamp\www\laravel-5.1\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\VerifyCsrfToken.php
line 137 at VerifyCsrfToken->addCookieToResponse(object(Request),
object(Response)) 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 124 at
Pipeline->Illuminate\Pipeline{closure}(object(Request)) at
call_user_func(object(Closure), object(Request)) in Pipeline.php line
30 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(BrowseController),
object(Route), object(Request), 'getBrowseRecent') in
ControllerDispatcher.php line 54 at
ControllerDispatcher->dispatch(object(Route), object(Request),
'App\Http\Controllers\BrowseController', 'getBrowseRecent') in
Route.php line 174 at Route->runController(object(Request)) in
Route.php line 140 at Route->run(object(Request)) in Router.php line
703 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)) in
ViewThrottleMiddleware.php line 55 at
ViewThrottleMiddleware->handle(object(Request), object(Closure)) at
call_user_func_array(array(object(ViewThrottleMiddleware), '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
30 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 705 at
Router->runRouteWithinStack(object(Route), object(Request)) in
Router.php line 678 at Router->dispatchToRoute(object(Request)) in
Router.php line 654 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
139 at Pipeline->Illuminate\Pipeline{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
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
The storage folder is writable, and the session driver used is file. I searched the whole project for session(), but found it nowhere. What can I do to correct this error? Thanks!
The session.php is as follows:
<?php
return [
'driver' => env('SESSION_DRIVER', 'file'),
'lifetime' => 120,
'expire_on_close' => false,
'encrypt' => false,
'files' => storage_path('framework/sessions'),
'connection' => null,
'table' => 'sessions',
'lottery' => [2, 100],
'cookie' => 'laravel_session',
'path' => '/',
'domain' => null,
'secure' => false,
];
Edit 1: I found the problem is in the controller. There is a line:
$this->middleware('csrf', [ 'on' => 'post' ]);
I commented it out and it worked. But I didn't figure out why it caused the problem yet.

Look at #Cas Bloem his answer here this helped me out amazingly:
Laravel - Session store not set on request
That's why it wasn't working for me. Cause you're using a session that is expection matching CSRF tokens (is my best guess, I'm new to Laravel myself).
Also if you go to app->http->middleware->VerifyCsrfToken this is were you can add routes to the array that won't be checked for CSRF verification. This plus Cas Bloem his fix (place routes in different section in routes.php) fixed my problem. I'm just developing/learning on localhost right now but need to implement this later on.
Hope this helps/clears thing up!

Related

Error with Laravel file system after moving to new domain and hosting

So i have just run php composer.phar remove and the php composer.phar install and then artisan migrate after moving my site from one domain to another and changing database. This all went ok and no error appeared that i wasnt able to quickly fix that why i ran the composer remove. However im getting a weird cant find file error which i havent had before. I am not sure how to fix this or where i am going wrong. This is the error I am getting:
ErrorException in Filesystem.php line 109:
file_put_contents(/dfb46d0b690f78222831518b7c4c56c1dcef9f3b.php): failed to open stream: Permission denied
in Filesystem.php line 109
at HandleExceptions->handleError('2', 'file_put_contents(/dfb46d0b690f78222831518b7c4c56c1dcef9f3b.php): failed to open stream: Permission denied', '/home/danielma/public_html/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php', '109', array('path' => '/dfb46d0b690f78222831518b7c4c56c1dcef9f3b.php', 'contents' => '<?php $__env->startSection('content'); ?> <?php $__env->stopSection(); ?> <?php echo $__env->make('templates.' . $config->currentTemplate . '.standardLayouts.main', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>', 'lock' => false))
at file_put_contents('/dfb46d0b690f78222831518b7c4c56c1dcef9f3b.php', '<?php $__env->startSection('content'); ?> <?php $__env->stopSection(); ?> <?php echo $__env->make('templates.' . $config->currentTemplate . '.standardLayouts.main', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>', '0') in Filesystem.php line 109
at Filesystem->put('/dfb46d0b690f78222831518b7c4c56c1dcef9f3b.php', '<?php $__env->startSection('content'); ?> <?php $__env->stopSection(); ?> <?php echo $__env->make('templates.' . $config->currentTemplate . '.standardLayouts.main', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>') in BladeCompiler.php line 116
at BladeCompiler->compile('/home/danielma/public_html/resources/views/welcome.blade.php') in CompilerEngine.php line 51
at CompilerEngine->get('/home/danielma/public_html/resources/views/welcome.blade.php', array('__env' => object(Factory), 'app' => object(Application), 'errors' => object(ViewErrorBag), 'config' => object(stdClass))) in View.php line 149
at View->getContents() in View.php line 120
at View->renderContents() in View.php line 85
at View->render() in Response.php line 53
at Response->setContent(object(View)) in Response.php line 201
at Response->__construct(object(View)) in Router.php line 1085
at Router->prepareResponse(object(Request), object(View)) 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(MainController), object(Route), object(Request), 'homePage') in ControllerDispatcher.php line 54
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\MainController', 'homePage') 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
at require_once('/home/danielma/public_html/public/index.php') in index.php line 21
I am not sure where i have gone wrong so help would be greatly appreciated.
These are my current php setting: http://imgur.com/Yuv9UO4
Make sure the storage and bootstrap/cache folders have write permissions.
If you still get the error afterwards run php artisan view:clear and php artisan cache:clear.
From the docs under Installation > Configuration > Directory Permissions:
After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server or Laravel will not run.
Also check to make sure your .env file is correct.

Deploying Laravel on Heroku "PDOException in Connector.php line 55" (sqlite)

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.

How do I solve this "NotFoundHttpException" error in Laravel 5.1

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.

Pdo sqlite driver issue

I'm just beginning laravel and when i try to return articles JSON from sqlite, i get this driver error.
public function index(){
$articles = \App\Article::all();
return $articles;
}
Whoops, looks like something went wrong.
1/1 PDOException in Connector.php line 55: could not find driver
in Connector.php line 55
at PDO->__construct('sqlite:/srv/http/laravel/storage/database.sqlite', null, null, array('0', '2', '0', false, false)) in Connector.php line 55
at Connector->createConnection('sqlite:/srv/http/laravel/storage/database.sqlite', array('driver' => 'sqlite', 'database' => '/srv/http/laravel/storage/database.sqlite', 'prefix' => '', 'name' => 'sqlite'), array('0', '2', '0', false, false)) in SQLiteConnector.php line 37
at SQLiteConnector->connect(array('driver' => 'sqlite', 'database' => '/srv/http/laravel/storage/database.sqlite', 'prefix' => '', 'name' => 'sqlite')) in ConnectionFactory.php line 60
at ConnectionFactory->createSingleConnection(array('driver' => 'sqlite', 'database' => '/srv/http/laravel/storage/database.sqlite', 'prefix' => '', 'name' => 'sqlite')) in ConnectionFactory.php line 49
at ConnectionFactory->make(array('driver' => 'sqlite', 'database' => '/srv/http/laravel/storage/database.sqlite', 'prefix' => ''), 'sqlite') in DatabaseManager.php line 175
at DatabaseManager->makeConnection('sqlite') in DatabaseManager.php line 67
at DatabaseManager->connection(null) in Model.php line 3245
at Model::resolveConnection(null) in Model.php line 3211
at Model->getConnection() in Model.php line 1914
at Model->newBaseQueryBuilder() in Model.php line 1857
at Model->newQueryWithoutScopes() in Model.php line 1831
at Model->newQuery() in Model.php line 667
at Model::all() in ArticlesController.php line 14
at ArticlesController->index()
at call_user_func_array(array(object(ArticlesController), 'index'), array()) in Controller.php line 256
at Controller->callAction('index', array()) in ControllerDispatcher.php line 164
at ControllerDispatcher->call(object(ArticlesController), object(Route), 'index') in ControllerDispatcher.php line 112
at ControllerDispatcher->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 ControllerDispatcher.php line 114
at ControllerDispatcher->callWithinStack(object(ArticlesController), object(Route), object(Request), 'index') in ControllerDispatcher.php line 69
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\ArticlesController', 'index') in Route.php line 201
at Route->runWithCustomDispatcher(object(Request)) in Route.php line 134
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`enter code here`
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('/srv/http/laravel/public/index.php') in server.php line 21
Please be sure you've installedpdo and pdo_sqlite extensions properly.
php -v will output if are there any missing extension files.
You should have these packages sqlite, php5-sqlite . And built with pecl. pecl install pdo && pecl install pdo_sqlite . Lastly you should enable pdo, pdo_sqlite extensions in your php.ini. According to your phpinfo() output, your php.ini file is /etc/php/php.ini
And again according to your phpinfo() output, your extension folder is /usr/lib/php/modules/ . There should be pdo_sqlite.so file in this directory.
I found out that if we can write to the database, then the connection is working fine. We all faced the issue when trying to retrieve from database. I resolved this issue by restarting the server. That worked for me in Ubuntu 14.04

Laravel 5 Routing Issue - Bad Method Call Exception

I'm attempting to simply send a 'PUT' request to one of my routes (which is called as a resource in the route file), yet I recieve this traceback as the response.
Whoops, looks like something went wrong.
1/1 BadMethodCallException in Controller.php line 273: Method [show] does not exist.
in Controller.php line 273
at Controller->__call('show', array('1'))
at AccountControllerV2->show('1')
at call_user_func_array(array(object(AccountControllerV2), 'show'), array('account' => '1')) in Controller.php line 246
at Controller->callAction('show', array('account' => '1')) in ControllerDispatcher.php line 162
at ControllerDispatcher->call(object(AccountControllerV2), object(Route), 'show') in ControllerDispatcher.php line 107
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
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 ControllerDispatcher.php line 108
at ControllerDispatcher->callWithinStack(object(AccountControllerV2), object(Route), object(Request), 'show') in ControllerDispatcher.php line 67
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\API\V2\AccountControllerV2', 'show') in Route.php line 198
at Route->runWithCustomDispatcher(object(Request)) in Route.php line 131
at Route->run(object(Request)) in Router.php line 692
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in Authenticate.php line 47
at Authenticate->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 Router.php line 694
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 661
at Router->dispatchToRoute(object(Request)) in Router.php line 619
at Router->dispatch(object(Request)) in Kernel.php line 214
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in HttpsProtocol.php line 15
at HttpsProtocol->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 55
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 61
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 36
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 40
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
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
I cannot for the life of me figure out why this is happening.
Here is a code snippet from the Controller itself (which extends BaseController):
/**
* Update the currently logged User in storage.
*
* #return Response 201
* #return jsonArray account
* #return string message
*/
public function update($account_id) {
$input = Input::all();
$message = 'Account Successfully Updated';
$user = Auth::User();
And here is the Route declaration:
Route::group(array('prefix' => 'api/v2', 'namespace' => 'API\V2', 'middleware' => 'auth'), function()
{
Route::resource('challenges', 'ChallengeControllerV2', ['only'=> ['index','store','update','destroy']]);
Route::resource('groups', 'GroupControllerV2');
Route::resource('account', 'AccountControllerV2');
The call is being made to the correct path. Any ideas why I'm getting what seems to be an illogical response? There is no additional middleware/filters attached to the controller than what is shown.
It turns out that in Laravel 5 if you do not specify the resources available on a Route it will assume that they are all there (unlike in Laravel 4 where it checks to see what resources are available in all controllers). So I had to change the line like so.
Route::resource('account', 'AccountControllerV2', ['only'=> ['index','update','destroy']]);

Categories