laravel NotReadableException in Decoder.php - Unable to read image from file - php

So I am getting this error. After searching the internet it looks like the issue could be with the post_upload_size and post_size, but that's not it.
I upload larger images that work fine, then this image that has 1.5MB is not working. It's like it's random. It works for some, but not for all images. Here's the full output.
Whoops, looks like something went wrong:
1/1 NotReadableException in Decoder.php line 46: Unable to read image from file (/tmp/phpVpVQeP).
in Decoder.php line 46
at Decoder->initFromPath('/tmp/phpVpVQeP') in AbstractDecoder.php line 293
at AbstractDecoder->init('/tmp/phpVpVQeP') in AbstractDriver.php line 64
at AbstractDriver->init('/tmp/phpVpVQeP') in ImageManager.php line 50
at ImageManager->make('/tmp/phpVpVQeP') in Facade.php line 215
at Facade::__callStatic('make', array('/tmp/phpVpVQeP')) in ProfileController.php line 251
at Image::make('/tmp/phpVpVQeP') in ProfileController.php line 251
at ProfileController->sendProfile(object(Request), 'klaughlin')
at call_user_func_array(array(object(ProfileController), 'sendProfile'), array(object(Request), 'username' => 'klaughlin')) in Controller.php line 256
at Controller->callAction('sendProfile', array(object(Request), 'username' => 'klaughlin')) in ControllerDispatcher.php line 164
at ControllerDispatcher->call(object(ProfileController), object(Route), 'sendProfile') 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(ProfileController), object(Route), object(Request), 'sendProfile') in ControllerDispatcher.php line 69
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\ProfileController', 'sendProfile') in Route.php line 203
at Route->runWithCustomDispatcher(object(Request)) in Route.php line 134
at Route->run(object(Request)) in Router.php line 708
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 710
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 675
at Router->dispatchToRoute(object(Request)) in Router.php line 635
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 Cors.php line 18
at Cors->handle(object(Request), object(Closure))
at call_user_func_array(array(object(Cors), '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 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 122
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 87
at Kernel->handle(object(Request)) in index.php line 54
Here is my var_dump
object(Symfony\Component\HttpFoundation\File\UploadedFile)#30 (7) { ["test":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> bool(false) ["originalName":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> string(19) "20160212_124938.jpg" ["mimeType":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> string(10) "image/jpeg" ["size":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> int(1606199) ["error":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> int(0) ["pathName":"SplFileInfo":private]=> string(14) "/tmp/phpVpVQeP" ["fileName":"SplFileInfo":private]=> string(9) "phpVpVQeP" } string(14) "1483214733.jpg" string(76) "/home/laughlindavid/public_html/mealog.com/public/profilepics/1483214733.jpg"
It is odd how it just does this with certain images.
Here is the code in my controller.
$image = Input::file('picture');
var_dump($image);
$filename = time() . '.' . $image->getClientOriginalExtension();
var_dump($filename);
$path = public_path('profilepics/' . $filename);
var_dump($path);
Image::make($image->getRealPath())->resize(200, 200)->save($path);

I had the same problem. I've solved the problem after installing imagick driver and setting driver to imagick (config/image.php) instead of GD.

This error may have many different solutions, but I'm hoping this will help someone out there. The short answer was that my php version which is 5.6 throws a gd.jpeg warning which probably caused it to not show as a gd resource when I did a var_dump in my intervention image Decoder.php file. Maybe using image Imagick driver instead of GD driver would have fixed this issue. BUT I USED THIS TO IGNORE THE WARNING, which PHP VERSION 1.7 now does automatically.
ini_set ('gd.jpeg_ignore_warning', 1);error_reporting(E_ALL & ~E_NOTICE);
So horray! My now all images uploaded consistently, but there was another issue I think related to this. My images had EXIF data in them which caused some of them to rotate automatically which was strange. Luckily Intervention Image has a method for this "orientate()" which I use when I create my image. Here's my new code in controller.
$image = $picture;
echo '<br>';
$filename = time() . '.' . $image->getClientOriginalExtension();
$path = public_path('profilepics/' . $filename);
$imageMoved = $image->move(public_path('profilepics'), $filename);
ini_set ('gd.jpeg_ignore_warning', 1);
error_reporting(E_ALL & ~E_NOTICE);
Image::make($path)->resize(200,200)->orientate()->save($path);
I really hope this saves you the major time I spent reading through totally different issues throwing the same error. My advice would be to var dump the crap out of the files your errors are coming from and compare (at least for my case) the working images from the non-working ones. Peace and Happy Coding!

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.

Laravel 5: InvalidArgumentException in DateComparator.php line 38

I keep getting this error:
Laravel 5: InvalidArgumentException in DateComparator.php line 38
If I refresh the page it will work fine: it only happens on the first load.
Whoops, looks like something went wrong.
1/1
InvalidArgumentException in DateComparator.php line 38:
"now - 3.0E+12 seconds" is not a valid date.
in DateComparator.php line 38
at DateComparator->__construct('<= now - 3.0E+12 seconds') in Finder.php line 249
at Finder->date('<= now - 3.0E+12 seconds') in FileSessionHandler.php line 91
at FileSessionHandler->gc('3.0E+12') in StartSession.php line 150
at StartSession->collectGarbage(object(Store)) in StartSession.php line 70
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 118
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 86
at Kernel->handle(object(Request)) in index.php line 54

laravel 5: sending email does not work

I'm new to laravel and am currently stuck when trying to send an email like this:
Mail::send('emails.pwreset', $mydata, function ($message) use ($mydata) {
$message->from('foo#bar.de', 'Password reset');
how can I enable/configure the mailing function?
here's my laravel error message:
Swift_TransportException in StreamBuffer.php line 294: Process could not be started [Das System kann den angegebenen Pfad nicht finden.
]
in StreamBuffer.php line 294
at Swift_Transport_StreamBuffer->_establishProcessConnection() in StreamBuffer.php line 58
at Swift_Transport_StreamBuffer->initialize(array('timeout' => '30', 'blocking' => '1', 'command' => '/usr/sbin/sendmail -bs', 'type' => '16')) in AbstractSmtpTransport.php line 113
at Swift_Transport_AbstractSmtpTransport->start() in SendmailTransport.php line 51
at Swift_Transport_SendmailTransport->start() in Mailer.php line 79
at Swift_Mailer->send(object(Swift_Message), array()) in Mailer.php line 398
at Mailer->sendSwiftMessage(object(Swift_Message)) in Mailer.php line 188
at Mailer->send('emails.pwreset', array('passwort' => 'WVSSV', 'empf' => 'foo#bar.de'), object(Closure)) in Facade.php line 216
at Facade::__callStatic('send', array('emails.pwreset', array('passwort' => 'WVSSV', 'empf' => 'foo#bar.de'), object(Closure))) in ResetpwController.php line 58
at Mail::send('emails.pwreset', array('passwort' => 'WVSSV', 'empf' => 'foo#bar.de'), object(Closure)) in ResetpwController.php line 58
at ResetpwController->resetted(object(Request))
at call_user_func_array(array(object(ResetpwController), 'resetted'), array(object(Request))) in Controller.php line 256
at Controller->callAction('resetted', array(object(Request))) in ControllerDispatcher.php line 164
at ControllerDispatcher->call(object(ResetpwController), object(Route), 'resetted') 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(ResetpwController), object(Route), object(Request), 'resetted') in ControllerDispatcher.php line 69
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\Resetpw\ResetpwController', 'resetted') 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 ShareErrorsFromSession.php line 54
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
It looks like /usr/sbin/sendmail does not exist. Is sendmail installed and properly configured?
Also check the Swift Mailer settings inside your application.

Required #SWG\Info() not found

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

Categories