Laravel Routing issue when using POST Method - laravel

I am trying to call controller using Routes. Everything is working fine when using GET method. When I worked on Post, i am not able to call the controller. Please check the below.
Error Code: Routing is not working
Route::post('/accountSignUp', [
'as' => 'accountSignUp',
'uses' => 'UsersController#accountSignUp'
]);
can anybody suggest how to do it.
I checked in log.. Getting the below error message..
[2014-11-07 13:30:46] dev.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in /var/www/project_name/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php:148
Stack trace:
#0 /var/www/project_name/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1049): Illuminate\Routing\RouteCollection->match(Object(Illuminate\Http\Request))
#1 /var/www/project_name/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1017): Illuminate\Routing\Router->findRoute(Object(Illuminate\Http\Request))
#2 /var/www/project_name/vendor/laravel/framework/src/Illuminate/Routing/Router.php(996): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#3 /var/www/project_name/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(775): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#4 /var/www/project_name/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(745): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#5 /var/www/project_name/vendor/barryvdh/laravel-debugbar/src/Middleware/Stack.php(34): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#6 /var/www/project_name/vendor/laravel/framework/src/Illuminate/Session/Middleware.php(72): Barryvdh\Debugbar\Middleware\Stack->handle(Object(Illuminate\Http\Request), 1, true)
#7 /var/www/project_name/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php(47): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#8 /var/www/project_name/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php(51): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#9 /var/www/project_name/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#10 /var/www/project_name/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(641): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#11 /var/www/project_name/public/index.php(49): Illuminate\Foundation\Application->run()
#12 {main} [] []

First, you should have defined your routes this way:
Route::method(['POST', 'GET'], '/accountSignUp', [
'as' => 'accountSignUp',
'uses' => 'UsersController#accountSignUp'
]);
Now in your controller to get any values you can simply use echo Input::get('username') - you use get method both for POST and GET data.

Related

You must define a binary prior to conversion. Snappy for Laravel 9

I've got this LogicException with Laravel 9 on Mac OS Monterey 12.3.1.
I have download wkhtmltopdf binary
Check binary path (/usr/local/bin/wkhtmltopdf and /usr/local/bin/wkhtmltoimage)
Make a chmod +x to binaries
Install composer package via composer require barryvdh/laravel-snappy
Adding config snapy via php artisan vendor:publish --provider="Barryvdh\Snappy\ServiceProvider"
define to my .envfile needed variables (WKHTML_PDF_BINARY & WKHTML_IMG_BINARY)
This is my snappy.php file for config : (automaticly generated)
<?php
return [
/*
|--------------------------------------------------------------------------
| Snappy PDF / Image Configuration
|--------------------------------------------------------------------------
|
| This option contains settings for PDF generation.
|
| Enabled:
|
| Whether to load PDF / Image generation.
|
| Binary:
|
| The file path of the wkhtmltopdf / wkhtmltoimage executable.
|
| Timout:
|
| The amount of time to wait (in seconds) before PDF / Image generation is stopped.
| Setting this to false disables the timeout (unlimited processing time).
|
| Options:
|
| The wkhtmltopdf command options. These are passed directly to wkhtmltopdf.
| See https://wkhtmltopdf.org/usage/wkhtmltopdf.txt for all options.
|
| Env:
|
| The environment variables to set while running the wkhtmltopdf process.
|
*/
'pdf' => [
'enabled' => true,
'binary' => env('WKHTML_PDF_BINARY', '/usr/local/bin/wkhtmltopdf'),
'timeout' => false,
'options' => [],
'env' => [],
],
'image' => [
'enabled' => true,
'binary' => env('WKHTML_IMG_BINARY', '/usr/local/bin/wkhtmltoimage'),
'timeout' => false,
'options' => [],
'env' => [],
],
];
My routes/web.php file :
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\MyController;
Route::controller(MyController::class)->group(function () {
Route::get('/1', 'showStepOne')->name('show.step.one');
Route::get('/pdf', 'showPDF')->name('show.pdf');
});
My Laravel Controller :
<?php
namespace App\Http\Controllers;
use \Illuminate\Http\Request;
use \Illuminate\Http\Response;
use Knp\Snappy\Pdf;
use Illuminate\Support\Facades\View;
class MyController extends Controller
{
/**
* Display 1st step.
*
* #return \Illuminate\Http\Response
*/
public function showStepOne()
{
return view('1');
}
/**
* Show the PDF generated
*
* #param Illuminate\Http\Request $request
* #param Knp\Snappy\Pdf $snappy
* #return \Illuminate\Http\Response
*/
public function showPDF(Request $request, Pdf $snappy): Response
{
$pdf = $request->session()->get('pdf');
if(empty($pdf)) return redirect()->route('show.step.one');
$html = View::make("my_pdf", array(
'tags' => $pdf['tags'],
'workperformance' => $pdf['workperformance']
));
$options = [
'Content-Type' => 'application/pdf',
'Content-Disposition' => 'inline; filename="diagnostic.pdf"'
];
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || strpos($_SERVER['HTTP_USER_AGENT'], 'Trident') !== false) {
$options += [
'Cache-Control' => 'max-age=1',
'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0',
'Pragma' => 'public',
'Expires' => '0'
];
}
return new Response(
$snappy->getOutputFromHtml(
array($html),
array(
'page-size' => 'A4',
'margin-top' => '0in',
'margin-right' => '0in',
'margin-bottom' => '0in',
'margin-left' => '0in',
'encoding' => "UTF-8",
)
),
200,
$options
);
}
And the complete error (in laravel.log) :
[2022-06-16 14:20:48] dev.ERROR: You must define a binary prior to conversion. {"exception":"[object] (LogicException(code: 0): You must define a binary prior to conversion. at /var/www/html/vendor/knplabs/knp-snappy/src/Knp/Snappy/AbstractGenerator.php:301)
[stacktrace]
#0 /var/www/html/vendor/knplabs/knp-snappy/src/Knp/Snappy/AbstractGenerator.php(180): Knp\\Snappy\\AbstractGenerator->getCommand()
#1 /var/www/html/vendor/knplabs/knp-snappy/src/Knp/Snappy/Pdf.php(36): Knp\\Snappy\\AbstractGenerator->generate()
#2 /var/www/html/vendor/knplabs/knp-snappy/src/Knp/Snappy/AbstractGenerator.php(242): Knp\\Snappy\\Pdf->generate()
#3 /var/www/html/vendor/knplabs/knp-snappy/src/Knp/Snappy/AbstractGenerator.php(261): Knp\\Snappy\\AbstractGenerator->getOutput()
#4 /var/www/html/app/Http/Controllers/EnergyDiagnosisController.php(932): Knp\\Snappy\\AbstractGenerator->getOutputFromHtml()
#5 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\\Http\\Controllers\\EnergyDiagnosisController->showPDF()
#6 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction()
#7 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(261): Illuminate\\Routing\\ControllerDispatcher->dispatch()
#8 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(204): Illuminate\\Routing\\Route->runController()
#9 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(725): Illuminate\\Routing\\Route->run()
#10 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
#11 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#12 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()
#13 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#14 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()
#15 /var/www/html/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#16 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()
#17 /var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#18 /var/www/html/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()
#19 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Session\\Middleware\\StartSession->handle()
#20 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#21 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()
#22 /var/www/html/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#23 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()
#24 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#25 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(726): Illuminate\\Pipeline\\Pipeline->then()
#26 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(703): Illuminate\\Routing\\Router->runRouteWithinStack()
#27 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(667): Illuminate\\Routing\\Router->runRoute()
#28 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(656): Illuminate\\Routing\\Router->dispatchToRoute()
#29 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(167): Illuminate\\Routing\\Router->dispatch()
#30 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()
#31 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#32 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#33 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle()
#34 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#35 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#36 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle()
#37 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#38 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()
#39 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#40 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle()
#41 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#42 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Http\\Middleware\\HandleCors->handle()
#43 /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#44 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Http\\Middleware\\TrustProxies->handle()
#45 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#46 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(142): Illuminate\\Pipeline\\Pipeline->then()
#47 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
#48 /var/www/html/public/index.php(52): Illuminate\\Foundation\\Http\\Kernel->handle()
#49 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/resources/server.php(16): require_once('...')
#50 {main}
I also try to clean Laravel's cache.
What I've missed ? According to the official documentation nothing is needed anymore but it doesn't work anyway.

Laravel SQS queue on localstack returns errors when running it

I have an empty Job file:
<?php
namespace SS\Jobs;
use Exception;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Log;
class SJQJob implements ShouldQueue
{
protected $payload;
public function __construct($payload)
{
$this->payload = $payload;
}
public function handle()
{
Log::info('!!!! Handle');
}
public function failed(Exception $exception)
{
Log::info('!!!! Failed');
}
}
I am dispatching this, then using php artisan queue:work ssqjobrequest I can see it being processed (2020-07-29 16:43:07][06978486-4c62-3948-5b4a-f8c648038c34] Processing: SS\Jobs\SJQJob)
The problem is that I am seeing this message in the log:
2020-07-29 16:43:07] local.ERROR: Error executing "DeleteMessage" on "http://localstack.test:4576/000000000000/ssqjobrequest"; AWS HTTP error: Client error: `POST http://localstack.test:4576/000000000000/ssqjobrequest` resulted in a `400 Bad Request` response:
<?xml version="1.0" encoding="UTF-8"?>
<ErrorResponse>
<Errors>
<Error>
<Code>ReceiptHandleIsInvalid (truncated...)
ReceiptHandleIsInvalid (client): The input receipt handle is invalid. - <?xml version="1.0" encoding="UTF-8"?>
<ErrorResponse>
<Errors>
<Error>
<Code>ReceiptHandleIsInvalid</Code>
<Message>The input receipt handle is invalid.</Message>
</Error>
</Errors>
<RequestID>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestID>
</ErrorResponse> {"exception":"[object] (Aws\\Sqs\\Exception\\SqsException(code: 0): Error executing \"DeleteMessage\" on \"http://localstack.test:4576/000000000000/ssqjobrequest\"; AWS HTTP error: Client error: `POST http://localstack.test:4576/000000000000/ssqjobrequest` resulted in a `400 Bad Request` response:
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<ErrorResponse>
<Errors>
<Error>
<Code>ReceiptHandleIsInvalid (truncated...)
ReceiptHandleIsInvalid (client): The input receipt handle is invalid. - <?xml version=\"1.0\" encoding=\"UTF-8\"?>
<ErrorResponse>
<Errors>
<Error>
<Code>ReceiptHandleIsInvalid</Code>
<Message>The input receipt handle is invalid.</Message>
</Error>
</Errors>
<RequestID>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</RequestID>
</ErrorResponse> at /var/www/sst/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php:195)
[stacktrace]
#0 /var/www/sst/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php(97): Aws\\WrappedHttpHandler->parseError()
#1 /var/www/sst/vendor/guzzlehttp/promises/src/Promise.php(198): Aws\\WrappedHttpHandler->Aws\\{closure}()
#2 /var/www/sst/vendor/guzzlehttp/promises/src/Promise.php(169): GuzzleHttp\\Promise\\Promise::callHandler()
#3 /var/www/sst/vendor/guzzlehttp/promises/src/RejectedPromise.php(40): GuzzleHttp\\Promise\\Promise::GuzzleHttp\\Promise\\{closure}()
#4 /var/www/sst/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\\Promise\\RejectedPromise::GuzzleHttp\\Promise\\{closure}()
#5 /var/www/sst/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(118): GuzzleHttp\\Promise\\TaskQueue->run()
#6 /var/www/sst/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(145): GuzzleHttp\\Handler\\CurlMultiHandler->tick()
#7 /var/www/sst/vendor/guzzlehttp/promises/src/Promise.php(241): GuzzleHttp\\Handler\\CurlMultiHandler->execute()
#8 /var/www/sst/vendor/guzzlehttp/promises/src/Promise.php(218): GuzzleHttp\\Promise\\Promise->invokeWaitFn()
#9 /var/www/sst/vendor/guzzlehttp/promises/src/Promise.php(262): GuzzleHttp\\Promise\\Promise->waitIfPending()
#10 /var/www/sst/vendor/guzzlehttp/promises/src/Promise.php(220): GuzzleHttp\\Promise\\Promise->invokeWaitList()
#11 /var/www/sst/vendor/guzzlehttp/promises/src/Promise.php(262): GuzzleHttp\\Promise\\Promise->waitIfPending()
#12 /var/www/sst/vendor/guzzlehttp/promises/src/Promise.php(220): GuzzleHttp\\Promise\\Promise->invokeWaitList()
#13 /var/www/sst/vendor/guzzlehttp/promises/src/Promise.php(61): GuzzleHttp\\Promise\\Promise->waitIfPending()
#14 /var/www/sst/vendor/aws/aws-sdk-php/src/AwsClientTrait.php(58): GuzzleHttp\\Promise\\Promise->wait()
#15 /var/www/sst/vendor/aws/aws-sdk-php/src/AwsClientTrait.php(86): Aws\\AwsClient->execute()
#16 /var/www/sst/vendor/laravel/framework/src/Illuminate/Queue/Jobs/SqsJob.php(71): Aws\\AwsClient->__call()
#17 /var/www/sst/vendor/dusterio/laravel-plain-sqs/src/Integrations/LaravelServiceProvider.php(28): Illuminate\\Queue\\Jobs\\SqsJob->delete()
#18 /var/www/sst/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(369): Dusterio\\PlainSqs\\Integrations\\LaravelServiceProvider->Dusterio\\PlainSqs\\Integrations\\{closure}()
#19 /var/www/sst/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(218): Illuminate\\Events\\Dispatcher->Illuminate\\Events\\{closure}()
#20 /var/www/sst/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(509): Illuminate\\Events\\Dispatcher->dispatch()
#21 /var/www/sst/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(370): Illuminate\\Queue\\Worker->raiseAfterJobEvent()
#22 /var/www/sst/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(314): Illuminate\\Queue\\Worker->process()
#23 /var/www/sst/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(134): Illuminate\\Queue\\Worker->runJob()
#24 /var/www/sst/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(112): Illuminate\\Queue\\Worker->daemon()
#25 /var/www/sst/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(96): Illuminate\\Queue\\Console\\WorkCommand->runWorker()
#26 [internal function]: Illuminate\\Queue\\Console\\WorkCommand->handle()
#27 /var/www/sst/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array()
#28 /var/www/sst/vendor/laravel/framework/src/Illuminate/Container/Util.php(36): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#29 /var/www/sst/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\\Container\\Util::unwrapIfClosure()
#30 /var/www/sst/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\\Container\\BoundMethod::callBoundMethod()
#31 /var/www/sst/vendor/laravel/framework/src/Illuminate/Container/Container.php(590): Illuminate\\Container\\BoundMethod::call()
#32 /var/www/sst/vendor/laravel/framework/src/Illuminate/Console/Command.php(134): Illuminate\\Container\\Container->call()
#33 /var/www/sst/vendor/symfony/console/Command/Command.php(255): Illuminate\\Console\\Command->execute()
#34 /var/www/sst/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\\Component\\Console\\Command\\Command->run()
#35 /var/www/sst/vendor/symfony/console/Application.php(1001): Illuminate\\Console\\Command->run()
#36 /var/www/sst/vendor/symfony/console/Application.php(271): Symfony\\Component\\Console\\Application->doRunCommand()
#37 /var/www/sst/vendor/symfony/console/Application.php(147): Symfony\\Component\\Console\\Application->doRun()
#38 /var/www/sst/vendor/laravel/framework/src/Illuminate/Console/Application.php(93): Symfony\\Component\\Console\\Application->run()
#39 /var/www/sst/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(131): Illuminate\\Console\\Application->run()
#40 /var/www/sst/artisan(35): Illuminate\\Foundation\\Console\\Kernel->handle()
I am not trying to delete anything (so I guess that laravel tries to delete the message from Amazon SQS) .. but why does it fail?
I have checked and the message gets there .. so why would it fail when trying to delete it ?
Thanks!
It seems like you are listening to your own machine instead of listening to aws
if you want to use ssqjobrequest you must also have a config for it
Does your queue config file look like this?
'default' => env('QUEUE_CONNECTION', 'sqs'),
'connections' => [
'sqs' => [
'driver' => 'sqs',
'key' => env('AWS_ACCESS_KEY_ID', ''),
'secret' => env('AWS_SECRET_ACCESS_KEY', ''),
'queue' => env('QUEUE'),
'region' => 'eu-west-1',
],
'ssqjobrequest' => [
'driver' => 'sqs',
'key' => env('AWS_ACCESS_KEY_ID', ''),
'secret' => env('AWS_SECRET_ACCESS_KEY', ''),
'queue' => env('ssqjobrequest'),
'region' => 'eu-west-1',
],
],
Does the env file contains queue with the full aws url?
QUEUE=https://sqs.eu-west-1.amazonaws.com/************/queue
ssqjobrequest=https://sqs.eu-west-1.amazonaws.com/************/ssqjobrequest
if you want to push a job to ssqjobrequest
SJQJob::dispatch($payload)->onQueue('ssqjobrequest');

Cannot use 'EVAL' with redis-cluster

Redis was working okay on local machine but on production it is throwing error.
On the local machine, I used the same configuration.
Trying for hours but still could not solve the problem.
Production Environment :
Ubuntu
Stack : Laravel, Redis, Laravel echo server
config/database.php
'redis' => [
'client' => 'predis',
'cluster' => false,
'default' => [
[
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => 0,
],
],
],
.env file
BROADCAST_DRIVER=redis
CACHE_DRIVER=redis
SESSION_DRIVER=file
Error :
Cannot use 'EVAL' with redis-cluster. {"exception":"[object] (Predis\\NotSupportedException(code: 0): Cannot use 'EVAL' with redis-cluster. at /var/www/html/mayaapi/vendor/predis/predis/src/Connection/Aggregate/RedisCluster.php:380)
[stacktrace]
#0 /var/www/html/mayaapi/vendor/predis/predis/src/Connection/Aggregate/RedisCluster.php(550): Predis\\Connection\\Aggregate\\RedisCluster->getConnection(Object(Predis\\Command\\ServerEval))
#1 /var/www/html/mayaapi/vendor/predis/predis/src/Connection/Aggregate/RedisCluster.php(593): Predis\\Connection\\Aggregate\\RedisCluster->retryCommandOnFailure(Object(Predis\\Command\\ServerEval), 'executeCommand')
#2 /var/www/html/mayaapi/vendor/predis/predis/src/Client.php(331): Predis\\Connection\\Aggregate\\RedisCluster->executeCommand(Object(Predis\\Command\\ServerEval))
#3 /var/www/html/mayaapi/vendor/predis/predis/src/Client.php(314): Predis\\Client->executeCommand(Object(Predis\\Command\\ServerEval))
#4 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Redis/Connections/Connection.php(96): Predis\\Client->__call('eval', Array)
#5 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Redis/Connections/Connection.php(108): Illuminate\\Redis\\Connections\\Connection->command('eval', Array)
#6 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Queue/RedisQueue.php(204): Illuminate\\Redis\\Connections\\Connection->__call('eval', Array)
#7 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Queue/RedisQueue.php(187): Illuminate\\Queue\\RedisQueue->migrateExpiredJobs('queues:default:...', 'queues:default')
#8 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Queue/RedisQueue.php(163): Illuminate\\Queue\\RedisQueue->migrate('queues:default')
#9 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(246): Illuminate\\Queue\\RedisQueue->pop('default')
#10 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(107): Illuminate\\Queue\\Worker->getNextJob(Object(Illuminate\\Queue\\RedisQueue), 'default')
#11 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(101): Illuminate\\Queue\\Worker->daemon('redis', 'default', Object(Illuminate\\Queue\\WorkerOptions))
#12 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(85): Illuminate\\Queue\\Console\\WorkCommand->runWorker('redis', 'default')
#13 [internal function]: Illuminate\\Queue\\Console\\WorkCommand->handle()
#14 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#15 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#16 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#17 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Container/Container.php(564): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#18 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Console/Command.php(179): Illuminate\\Container\\Container->call(Array)
#19 /var/www/html/mayaapi/vendor/symfony/console/Command/Command.php(255): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#20 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Console/Command.php(166): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#21 /var/www/html/mayaapi/vendor/symfony/console/Application.php(1012): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#22 /var/www/html/mayaapi/vendor/symfony/console/Application.php(272): Symfony\\Component\\Console\\Application->doRunCommand(Object(Illuminate\\Queue\\Console\\WorkCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#23 /var/www/html/mayaapi/vendor/symfony/console/Application.php(148): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#24 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Console/Application.php(89): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#25 /var/www/html/mayaapi/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#26 /var/www/html/mayaapi/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#27 {main}
"}
Try adding hash-tags (wrapping a constant string with {}) to your queue name in your config/queue.php file.
'queue.connections.redis.queue' => '{default}'
If you are using other queues besides the default, instead of OnQueue('myQueue') change it everywhere to OnQueue('{myQueue}').
Even if you are not using a cluster, probably predis is checking all keys passed to the Lua script are on the same node.

guzzle post requests returns malformed error

I try to run passport '/oauth/clients' method to create new passport's client with guzzle and got
local.ERROR: cURL error 3: <url> malformed error
I do :
$app_root_url = config('app.url');
\Log::info('-1 REGISTER $app_root_url::');
\Log::info($app_root_url);
$headers = [
'content-type' => 'application/json',
'verify' => true,
];
$guzzleClient = new \GuzzleHttp\Client();
$url = '/oauth/clients';
$requestBody['name'] = $newUser->name;
$requestBody['redirect'] = $app_root_url . '/callback';
// $requestBody['Accept'] = 'application/json'; // Do I need this parameter ?
\Log::info('-2 REGISTER $requestBody::');
\Log::info($requestBody);
$request = $guzzleClient->post( $url, [
"headers" => $headers, // Do I need these params ?
'form_params' => $requestBody // ERROR REFERING THIS LINE
]);
$response = $request->send();
\Log::info('-3 REGISTER $response::');
\Log::info($response);
I log file I see :
local.INFO: -1 REGISTER $app_root_url::
local.INFO: http://local-hostels3-backend-api.com
local.INFO: -2 REGISTER $requestBody::
local.INFO: array (
'name' => 'admin',
'redirect' => 'http://local-hostels3-backend-api.com/callback',
)
local.ERROR: cURL error 3: <url> malformed (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) {"exception":"[object] (GuzzleHttp\\Exception\\RequestException(code: 0): cURL error 3: <url> malformed (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) at /mnt/_work_sdb8/wwwroot/lar/hostels3-backend-api/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:201)
[stacktrace]
#0 /mnt/_work_sdb8/wwwroot/lar/hostels3-backend-api/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(155): GuzzleHttp\\Handler\\CurlFactory::createRejection(Object(GuzzleHttp\\Handler\\EasyHandle), Array)
#1 /mnt/_work_sdb8/wwwroot/lar/hostels3-backend-api/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(105): GuzzleHttp\\Handler\\CurlFactory::finishError(Object(GuzzleHttp\\Handler\\CurlHandler), Object(GuzzleHttp\\Handler\\EasyHandle), Object(GuzzleHttp\\Handler\\CurlFactory))
#2 /mnt/_work_sdb8/wwwroot/lar/hostels3-backend-api/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php(43): GuzzleHttp\\Handler\\CurlFactory::finish(Object(GuzzleHttp\\Handler\\CurlHandler), Object(GuzzleHttp\\Handler\\EasyHandle), Object(GuzzleHttp\\Handler\\CurlFactory))
#3 /mnt/_work_sdb8/wwwroot/lar/hostels3-backend-api/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php(28): GuzzleHttp\\Handler\\CurlHandler->__invoke(Object(GuzzleHttp\\Psr7\\Request), Array)
#4 /mnt/_work_sdb8/wwwroot/lar/hostels3-backend-api/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php(51): GuzzleHttp\\Handler\\Proxy::GuzzleHttp\\Handler\\{closure}(Object(GuzzleHttp\\Psr7\\Request), Array)
#5 /mnt/_work_sdb8/wwwroot/lar/hostels3-backend-api/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php(66): GuzzleHttp\\Handler\\Proxy::GuzzleHttp\\Handler\\{closure}(Object(GuzzleHttp\\Psr7\\Request), Array)
#6 /mnt/_work_sdb8/wwwroot/lar/hostels3-backend-api/vendor/guzzlehttp/guzzle/src/Middleware.php(29): GuzzleHttp\\PrepareBodyMiddleware->__invoke(Object(GuzzleHttp\\Psr7\\Request), Array)
#7 /mnt/_work_sdb8/wwwroot/lar/hostels3-backend-api/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php(70): GuzzleHttp\\Middleware::GuzzleHttp\\{closure}(Object(GuzzleHttp\\Psr7\\Request), Array)
#8 /mnt/_work_sdb8/wwwroot/lar/hostels3-backend-api/vendor/guzzlehttp/guzzle/src/Middleware.php(59): GuzzleHttp\\RedirectMiddleware->__invoke(Object(GuzzleHttp\\Psr7\\Request), Array)
#9 /mnt/_work_sdb8/wwwroot/lar/hostels3-backend-api/vendor/guzzlehttp/guzzle/src/HandlerStack.php(71): GuzzleHttp\\Middleware::GuzzleHttp\\{closure}(Object(GuzzleHttp\\Psr7\\Request), Array)
#10 /mnt/_work_sdb8/wwwroot/lar/hostels3-backend-api/vendor/guzzlehttp/guzzle/src/Client.php(361): GuzzleHttp\\HandlerStack->__invoke(Object(GuzzleHttp\\Psr7\\Request), Array)
#11 /mnt/_work_sdb8/wwwroot/lar/hostels3-backend-api/vendor/guzzlehttp/guzzle/src/Client.php(163): GuzzleHttp\\Client->transfer(Object(GuzzleHttp\\Psr7\\Request), Array)
#12 /mnt/_work_sdb8/wwwroot/lar/hostels3-backend-api/vendor/guzzlehttp/guzzle/src/Client.php(183): GuzzleHttp\\Client->requestAsync('post', Object(GuzzleHttp\\Psr7\\Uri), Array)
#13 /mnt/_work_sdb8/wwwroot/lar/hostels3-backend-api/vendor/guzzlehttp/guzzle/src/Client.php(96): GuzzleHttp\\Client->request('post', '/oauth/clients', Array)
#14 /mnt/_work_sdb8/wwwroot/lar/hostels3-backend-api/app/Http/Controllers/AuthController.php(207): GuzzleHttp\\Client->__call('post', Array)
#15 [internal function]: App\\Http\\Controllers\\AuthController->register(Object(Illuminate\\Http\\Request))
In my app/Providers/AuthServiceProvider.php I added passport routes definition :
public function boot()
{
$this->registerPolicies();
Passport::routes();
}
...
"guzzlehttp/guzzle": "^6.5",
"laravel/framework": "^6.2",
"laravel/passport": "^8.1",
What raized this error and how to fix it ?
MODIFIED BLOCK:
I added parameter to my headers :
$headers = [
'content-type' => 'application/json',
'verify' => true,
'X-CSRF-TOKEN', csrf_token()
];
But debugging this array I see it containes :
array (
'content-type' => 'application/json',
'verify' => true,
0 => 'X-CSRF-TOKEN',
1 => NULL,
)
That is backend rest api app and I do not any form with csrf hidden in it.
Have I to init csrf in someway?
Thanks!
It seems like your $url variable is only having path sections missing any host it must target.
Prepend the variable with the route host and thus providing full URL value for the Guzzle client.
Probable solution:
$url = config('app.url') . '/oauth/clients';
EDIT
You can also set your app URL as the base URL for Guzzle client.

Mailgun Error 'The parameters passed to the API were invalid

I am using mailgun to help me with sending mails on laravel.
Here mail code:
$data = array('name' => ucfirst($customer_name),'email' => $email, 'ticket_id' => $ticket_id);
$mail_data = array('name' => ucfirst($customer_name),'email' => $email, 'mobile' => $contact, 'address' => $address, 'delivery_type' => ucfirst(Input::get('delivery_type')), 'pickup_type' => ucfirst(Input::get('pickup_type')), 'pickup_date' => $pickup_date, 'pickup_time' => $pickup_time, 'brand' => $brand_name, 'ticket_id' => $ticket_id, 'city' => $region_name);
Mailgun::send('emails.ticket', $mail_data , function($message) use($data)
{
$message->to($data['email'], $data['name'])
->bcc(array('myemail#mydomain.com, aotheremail#mydomain.com, onemore#mydomain.com, lastone#mydomain.com'))
->subject('Service Request! - '.$data['ticket_id']);
});
I checked the logs figured out:
[2016-12-29 05:58:58] production.ERROR: exception 'Mailgun\Connection\Exceptions\MissingRequiredParameters' with message 'The parameters passed to the API were invalid. Check your inputs! Sandbox subdomains are for test purposes only. Please add your own domain or add the address to authorized recipients in Account Settings.' in /var/www/html/mysite/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php:169
Stack trace:
#0 /var/www/html/mysite/vendor/mailgun/mailgun-php/src/Mailgun/Connection/RestClient.php(88): Mailgun\Connection\RestClient->responseHandler(Object(GuzzleHttp\Message\Response))
#1 /var/www/html/mysite/vendor/mailgun/mailgun-php/src/Mailgun/Mailgun.php(106): Mailgun\Connection\RestClient->post('sandbox798d350d...', Array, Array)
#2 /var/www/html/mysite/vendor/mailgun/mailgun-php/src/Mailgun/Mailgun.php(53): Mailgun\Mailgun->post('sandbox798d350d...', Array, Array)
#3 /var/www/html/mysite/vendor/bogardo/mailgun/src/Bogardo/Mailgun/Mailgun.php(104): Mailgun\Mailgun->sendMessage('sandbox798d350d...', Array, Array)
#4 /var/www/html/mysite/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(222): Bogardo\Mailgun\Mailgun->send('emails.ticket', Array, Object(Closure))
#5 /var/www/html/mysite/app/Http/Controllers/AppController.php(384): Illuminate\Support\Facades\Facade::__callStatic('send', Array)
#6 /var/www/html/mysite/app/Http/Controllers/AppController.php(384): Bogardo\Mailgun\Facades\Mailgun::send('emails.ticket', Array, Object(Closure))
#7 [internal function]: App\Http\Controllers\AppController->pickup_request()
#8 /var/www/html/mysite/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(256): call_user_func_array(Array, Array)
#9 /var/www/html/mysite/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(164): Illuminate\Routing\Controller->callAction('pickup_request', Array)
I am not able to figure where the problem is? is it the syntax error? or what could be wrong?
It used to work properly now it has stopped.
Thanks!
The error tells everything :)
The parameters passed to the API were invalid. Check your inputs! Sandbox subdomains are for test purposes only. Please add your own domain or add the address to authorized recipients in Account Settings.
In Mailgun, sandbox subdomains are only for testing. If you need to really sending out emails you will need to add your domain name into your mailgun acc, or add authorized recipients into your mailgun account settings.
So in this case, you will need to either add mydomain.com into your mailgun whitelisted domains, or add myemail#mydomain.com, aotheremail#mydomain.com, onemore#mydomain.com, lastone#mydomain.com into whitelisted emails.
Relevant docs: https://help.mailgun.com/hc/en-us/articles/217531258-Authorized-Recipients
Related Q&A: https://laracasts.com/discuss/channels/laravel/sending-emails-with-mailgun

Resources