Laraveldeep

Experience

28,690

2 Best Reply Awards

  • Member Since 1 Year Ago
  • 202 Lessons Completed
  • 0 Favorites

20th May, 2018

Laraveldeep left a reply on Strange "Cannot Find Module 'shebang-command'" Error On Npm Run Dev • 2 days ago

Finally I figured this out.

Its because I don't have libpng-dev installed on my fresh installation of Ubuntu.

This is required by pngquant-bin, which is required by laravel-mix. This somehow disturbed the installation of shebang-command and 'laravel-mix`.

Solution:

$sudo apt install ligpng-dev



And on laravel project

$ rm -rf node_modules
$ npm cache clear
$ npm install
$ npm run dev

Solved!

Laraveldeep left a reply on Strange "Cannot Find Module 'shebang-command'" Error On Npm Run Dev • 3 days ago

I even tried npm cache clean followed by npm install after removing node_modules. Only error I get is that fsevents is not insatalled. That should be fine becasue fsevents are for Mac OSX only.

npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
npm WARN optional Skipping failed optional dependency /watchpack/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
npm WARN optional Skipping failed optional dependency /webpack-dev-server/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
npm WARN [email protected] requires a peer of [email protected]^6.0.0 but none was installed.
npm ERR! Linux 4.15.0-20-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE

npm ERR! [email protected] postinstall: `node lib/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script 'node lib/install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the pngquant-bin package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node lib/install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs pngquant-bin
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls pngquant-bin
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www/html/myblog/npm-debug.log

But npm run dev still gives me same error.

19th May, 2018

Laraveldeep started a new conversation Strange "Cannot Find Module 'shebang-command'" Error On Npm Run Dev • 3 days ago

Hi,

I just set up new Ubuntu 18.04 and cloned my previously working project from repo.

composer install, npm install all went fine

But during npm run dev I am getting this error:

> @ dev /var/www/html/myblog
> npm run development


> @ development /var/www/html/myblog
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

module.js:549
    throw err;
    ^

Error: Cannot find module 'shebang-command'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/var/www/html/myblog/node_modules/cross-spawn/lib/util/readShebang.js:5:22)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

npm ERR! Linux 4.15.0-20-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "development"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules--config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ development script 'cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'.
npm ERR! Make sure you have the lamyblog version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www/html/myblog/npm-debug.log

npm ERR! Linux 4.15.0-20-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "dev"
npm ERR! node v8.10.0
npm ERR! npm  v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script 'npm run development'.
npm ERR! Make sure you have the lamyblog version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run development
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www/html/myblog/npm-debug.log

In my other machine it is working perfectly fine.

Any suggestion on this?

Thanks!

12th November, 2017

Laraveldeep left a reply on Using Blade Inside Of A Vue Templates Properly • 6 months ago

@jekinney is right

Let say our example vue component is <emailaddr></emailaddr>

Example Vue component:

<template>
    // few other things
    <p>{{ errorMessage }}</p>

</template>

<script>
export default {
    props: ['errorMessage'],
    // other stuffs

}
</script>

Example Blade:

@if ($errors->has('email'))
    <emailaddr></emailaddr>
@elseif 
    <emailaddr error-message="{{ $errors->first('email') }}"></emailaddr>
@endif

Laraveldeep left a reply on `input.files` Not Recognized In Single Page Vue Component • 6 months ago

My bad, I used computed instead of method.

Laraveldeep started a new conversation `input.files` Not Recognized In Single Page Vue Component • 6 months ago

Hi,

I am trying to move already tested file upload input field as single file Vue component. I have tested this script already and working fine while used on global scope but when the code is moved to component, I am getting the error.

computed: {
    myMethog: function(event) {
        var input = event.target;
        if(input.files && input.files[0]) {
            // do something here
        }
    }
}

Renderer is throwing this error

[Vue warn]: Error in render: "TypeError: Cannot read property 'files' of undefined"

why?

Same code works when it is not inside component.

10th November, 2017

Laraveldeep left a reply on Missing Required Client Configuration Options: Region While Trying To Implement S3 • 6 months ago

Well after upgrade and restarting tinker I am getting the correct setting and region issue is resolved.

Laraveldeep left a reply on Missing Required Client Configuration Options: Region While Trying To Implement S3 • 6 months ago

That's what I did initially (set those on .env). After that I hard coded that on filesystems.php.

On both case I am getting same error that region parameter is not set or missing.

cache is cleared too... Now I am getting null for everything like mentioned before.

Any other clue?

Laraveldeep left a reply on Missing Required Client Configuration Options: Region While Trying To Implement S3 • 6 months ago

@gregrobson

After update I got null for everything... really weird

>>> config('filesystems.disks.s3')
=> [
     "driver" => "s3",
     "key" => null,
     "secret" => null,
     "region" => null,
     "bucket" => null,
   ]
>>>

Laraveldeep left a reply on Missing Required Client Configuration Options: Region While Trying To Implement S3 • 6 months ago

I just upgraded Laravel from 5.5.14 to 5.5.20 with composer update just in case. Now I am getting null for everything from config.

Getting same error while tinkering

Storage::disk('s3')->files()

Weird

Laraveldeep left a reply on Missing Required Client Configuration Options: Region While Trying To Implement S3 • 6 months ago

@robrogers3

It gives me

[
            'driver' => 's3',
            'key' => env('AWS_KEY'),
            'secret' => env('AWS_SECRET'),
            'region' => env('AWS_REGION'),
            'bucket' => env('AWS_BUCKET'),
]

region is there. Not sure where is the fault. These are set from my environment file. I have tried also adding the settings on config/filesystems.php but still getting same message.

9th November, 2017

Laraveldeep left a reply on Missing Required Client Configuration Options: Region While Trying To Implement S3 • 6 months ago

Can somebody point me to right direction? I am not sure what's wrong with my current config.

7th November, 2017

Laraveldeep left a reply on Missing Required Client Configuration Options: Region While Trying To Implement S3 • 6 months ago

Thanks @Robstar

Just to test, I have tried playing with various region. However it have no effect. The error remains the same.

Seems like whatever I set on filesystem.php or .env the region variable is not propagated properly back to the driver. Well... not sure

Also the changes you have mentioned must be just recent ones.

I have a fresh installation of 5.5 from past release with these

        's3' => [
            'driver' => 's3',
            'key' => env('AWS_KEY'),
            'secret' => env('AWS_SECRET'),
            'region' => env('AWS_REGION'),
            'bucket' => env('AWS_BUCKET'),
        ],

Have tested it using the new keys but error still remains same.

I guess variable name changes in this regard doesn't matter. Whatever is in filesystem.php, if we have it on .env it won't be a problem.

Any other clue?

Laraveldeep started a new conversation Missing Required Client Configuration Options: Region While Trying To Implement S3 • 6 months ago

Hi,

I am trying to test my file upload sent to s3. I have already installed the package league/flysystem-aws-s3-v3 ~1.0

In my .env file I have set the credentials needed by config/filesystems.php like this:

AWS_KEY=my_key
AWS_SECRET=my_secret
AWS_REGION=us-east-1
AWS_BUCKET=my_bucket

However when I try to store the uploaded file, it is giving me this Error

File: 

vendor\aws\aws-sdk-php\src\ClientResolver.php


Message:

Missing required client configuration options: region: (string) A "region" configuration value is required for the "s3" service (e.g., "us-west-2"). A list of available public regions and endpoints can be found at http://docs.aws.amazon.com/general/latest/gr/rande.html.

I have no idea why it is throwing error and what to look for.

6th November, 2017

Laraveldeep left a reply on How To Show Error On Particular Field On Blade For Field Array? • 6 months ago

I found the solution quicker than I thought from my last posts answer

@if ($errors->has('photo.'.$number'))
    {{ $errors->first('photo.'.$number) }}
@endif

Key point it was not obvious to me was, we don't need to put braces inside blade directives.

Laraveldeep left a reply on How To Show Error On Particular Field On Blade For Field Array? • 6 months ago

I found the solution quicker than I thought from my last posts answer

@if ($errors->has('photo.'.$number'))
    {{ $errors->first('photo.'.$number) }}
@endif

Key point it was not obvious to me was, we don't need to put braces.

Laraveldeep left a reply on Error Message Not Showing For Dynamically Generated Form Elements • 6 months ago

Oh my bad.

What was I thinking :)

Thanks for pointing that out.

Laraveldeep started a new conversation How To Show Error On Particular Field On Blade For Field Array? • 6 months ago

My form field

<input class="file-input" type="file" name="photo[]" accept="image/*">

As per documentation (), my validation rule

'photo.*' => 'file|image|mimes:jpeg, bmp, png'

Lets say I have 6 of these fields.

When validation fails, i know it will flash the error message with particular field like:

photo.0
photo.1
and so on..

Question: How to catch that on blade so that I can show the error message only on particular filed where error occurred?

This doesn't work, when error occurs all fields shows error message

@if ($errors->has('photo.*'))

This doesn't get triggered either. Seems like value passed is not parsed at all.

@if ($errors->has('photo.{{ $number }}'))

Any idea or work around?

Laraveldeep started a new conversation Error Message Not Showing For Dynamically Generated Form Elements • 6 months ago

Hi,

I have form element which I generate using for loop depending upon how many I like and each element have error message associated with it.

Let's say:

<input name="myinput{{ $number }}" value="some_value">


@if ($errors->has('myinput{{ $number }}')) <---- This doesn't trigger when validation fails.
    <p class="help is-danger">
        {{ $errors->first('myinput{{ $number }}') }} <--- I know this is not allowed but this is my intention.
    </p>
@endif
  1. Why its not triggered?
  2. Is there a way around for what I am trying to do for showing message?

Thanks!

16th October, 2017

Laraveldeep left a reply on Laravel[5.5] Presets (Give It A Try) • 7 months ago

@codenex didn't know about that. Thanks for the info.

Anyway I have moved my project to organization https://github.com/laravel-frontend-presets

Some of the presets we maintain at this time are Bulma, Zurb Foundation and uikit3. https://packagist.org/packages/laravel-frontend-presets/

If you can contribute, kindly join.

Thanks!

5th October, 2017

Laraveldeep left a reply on Dynamic Content In Master Page Sidebar • 7 months ago

Not sure what is exactly required but I am guessing a kind of view composer type solution..

Have a look at this: https://laravel.com/docs/5.5/views#view-composers

19th August, 2017

Laraveldeep left a reply on Add/Update Cache Control Metadata On S3 Objects • 9 months ago

@Robstar yep I solved this using aws-cli... much quicker

2nd August, 2017

Laraveldeep left a reply on Response Code To SNS Subscription Confirmation Not Working • 9 months ago

@awhite yes I was able to solve this. My case was I forgot to set the subscription message as RAW. You can find that in AWS SNS console under other subscription actions -> edit subscription attributes. Because of this I was not able to get the JSON data I was expecting.

My code is similar to the one suggested by @martinbean

Just in case if you want to check this out here is my full code

AmazonSNSController.php

<?php

namespace App\Http\Controllers\AWS;

use Illuminate\Http\Request;

use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Storage;


class AmazonSNSController extends Controller
{


    // handle bounced emails
    public function handleBounces(Request $request)
    {

        // $bounce_simulator_email = '[email protected]';

        // get bounce message
        $payload = json_decode($request->getContent());


      if(property_exists($payload, 'Type'))
      {
        if($payload->Type === "SubscriptionConfirmation")
        {
            // if we are verifying notification subscription in this Endpoint for the
            // first time then go the said URL to confirm
            $confirmation_url = curl_init($payload->SubscribeURL);
            curl_exec($confirmation_url);
        }
      }
        else // process bounces
        {
        // You have to set "subscription attribute to RAW" on endpoints from SNS console to get JSON message
        $notificationType = $payload->notificationType;
        $bounceType = $payload->bounce->bounceType;
        $bounced_email = $payload->bounce->bouncedRecipients[0]->emailAddress; //get first email


        // take action
        if($notificationType === 'Bounce')
        {

            if($bounceType === "Transient")
            {
                // increment soft bounce count
                User::where(['email' => $bounced_email])->increment('softbounced');
            }
            else
            {
                // mark email as bounced permanently
                User::where(['email'=> $bounced_email])->update(['bounced' => 1]);
            }


            //mark as hard bounced for emails which has soft bounced count of 3 or more
            User::where(['email' => $bounced_email, 'softbounced' => 3])->update(['bounced' => 1]);

        }

        }

    }




    // handle email complaints
    public function handleComplains(Request $request)
    {

        // $complaint_simulator_email = '[email protected]';

      $payload = json_decode($request->getContent());


      if(property_exists($payload, 'Type'))
      {
        if($payload->Type == "SubscriptionConfirmation")
        {
          // if we are verifying notification subscription in this Endpoint for the
          // first time then go the said URL to confirm
          $confirmation_url = curl_init($payload->SubscribeURL);
          curl_exec($confirmation_url);
        }
      }
      else
      {
        // You have to set "subscription attribute to RAW" on endpoints from SNS console to get JSON message
        $notificationType = $payload->notificationType;
        $complaint_email = $payload->complaint->complainedRecipients[0]->emailAddress; // get the first one


        if($notificationType === 'Complaint')
        {
            // Mark complained for this email
            User::where(['email'=> $complaint_email])->update(['complained' => 1]);
        }
      }


  }

}


I have these columns on my users table.

Hope this helps.

22nd July, 2017

Laraveldeep started a new conversation Zurb Foundation 6 Preset For Laravel 5.5 • 10 months ago

As title says, try out this preset.

Pretty easy to use.

php artisan preset foundation // for basic preset

or

php artisan preset foundation-auth // for preset, Auth route entry and Foundation Auth views on single go

Details at: https://github.com/laravel-frontent-presets/zurb-foundation

https://packagist.org/packages/laravel-frontend-presets/zurb-foundation

Give it a try.

Feedback welcome

Thanks!

20th July, 2017

Laraveldeep left a reply on Getting 'r Is Not Defined' Error • 10 months ago

Orphaned r can be found here on app.js:

/**
 * Echo exposes an expressive API for subscribing to channels and listening
 * for events that are broadcast by Laravel. Echo and event broadcasting
 * allows your team to easily build robust real-time web applications.
 */

// import Echo from 'laravel-echo'

// window.Pusher = require('pusher-js');

// window.Echo = new Echo({
//     broadcaster: 'pusher',
//     key: 'your-pusher-key'
// });
r; <-----------------

Any clue?

All I did was changed the Jquery version down to 2.2.4.

Laraveldeep started a new conversation Getting 'r Is Not Defined' Error • 10 months ago

Hi,

I am testing the laravel dev version 5.5. After npm run dev I am seeing this error on console

Uncaught ReferenceError: r is not defined
    at Object.VERSION (app.js:15236)
    at __webpack_require__ (app.js:20)
    at Object.<anonymous> (app.js:15163)
    at __webpack_require__ (app.js:20)
    at Object.<anonymous> (app.js:15148)
    at __webpack_require__ (app.js:20)
    at app.js:63
    at app.js:66

Not sure what is causing this. Any idea?

Thanks!

18th July, 2017

Laraveldeep left a reply on Laravel[5.5] Zurb Foundation Preset • 10 months ago

Added Bulma.

Please give it a try and send feedback.

All you have to do is to laravel new myapp --dev then copy the folders as instructed here https://github.com/Laraveldeep/Laravel-Scaffolding-Presets

Thanks!

17th July, 2017

Laraveldeep left a reply on Laravel Executing GET Instead Of POST Request • 10 months ago

I suspect your form tag has missing action="URL" section

Laraveldeep started a new conversation Laravel[5.5] Zurb Foundation Preset • 10 months ago

Hi,

When I heard of Laravel preset on 5.5, I was wondering about the great feature plus what will be included and how to include my favorite framework if not present in bundle.

With this in mind, I started tinkering and came up with the working Zurb Foundation preset. During the pull request, it was denied that no more presets will be entertained. So thought of integrating and using presets in unofficial way.

This is the easiest method (unofficial) I came up with. Have tried and working perfectly fine. Kindly give it a try and tell what do you think.

Actually its not hard to do things manually either but if presets are available, it can save few more minutes.

Download the preset here: https://github.com/Laraveldeep/Laravel-Scaffolding-Presets

Thanks and peace!

14th July, 2017

Laraveldeep left a reply on Using Foundation Zurb 6.3.0 With Laravel 5.4 • 10 months ago

Exactly, this have in discussed on 5.3 thread. I found this tutorial with explanation.

http://somethingnewtutorial.blogspot.com/2017/07/using-foundation-6-with-laravel-5.html

Laraveldeep left a reply on Zurb Foundation For Sites V6 Tabs Not Working • 10 months ago

how did you install the foundation? via npm?

what about the correct version of Jquery used by foundation?

Take a look at this:

http://somethingnewtutorial.blogspot.com/2017/07/using-foundation-6-with-laravel-5.html

same process for L5.3 as well. You will be using gulp instead of laravel-mix.

Hope this helps.

Hope in L5.5 we already have preset for Foundation as well.

21st June, 2017

Laraveldeep left a reply on How To Keep Ordering Intact For Find By Array Collection? • 11 months ago

Long method solved the problem like this:

$mykeys = array(1,5,6,3,2,4);

$users = collect(); // https://laravel.com/docs/5.4/collections
foreach($mykeys as $key)
{
  $users->push(Users::find($key));
}

dd($users);

Still want to know if there is sweet short method.

Laraveldeep started a new conversation How To Find Records By Array But Keep Order Intact? • 11 months ago

Hi,

I need to fetch some records by passing array of primary key but I need the fetched records ordered according the passed key. How can I do that?

I noticed that it fetched the records but also sorts by primary key in ascending order. I need to prevent this.

No such thing mentioned on documentation: https://laravel.com/docs/5.4/eloquent#retrieving-single-models.

Basically what I am doing is:

$mykeys = array(1,5,6,3,2,4);

$users = Users::find($mykeys);

I am getting the collection but sorted. I want it sorted as per my key passed.

Thanks!

15th June, 2017

Laraveldeep left a reply on AWS SNS Topic Subscription Not Working • 11 months ago

Ok after few tests I am able to confirm the subscription.

The fault is in my 'VerifyCsrfToke` middleware entry.

Used this and it worked:

protected $except = [
    '/sns*',
];

Laraveldeep started a new conversation AWS SNS Topic Subscription Not Working • 11 months ago

Hi,

I am sending email from L5.3 application through AWS SES. I need to handle bounces and complains from sent email through SNS topic. So I have this for testing purpose:

web.php

Route::post('/sns/handle-bounces', 'AWS\[email protected]');
Route::post('/sns/handle-complains', 'AWS\[email protected]');

AmazonSNSController

public function handleBounces(Request $request)
{
  $payload = $request->getContent();
  Storage::put('public/payload.txt', $payload); //just write to text file what AWS SNS had sent
  die();
}

So I have added exception to these two methods at VerifyCsrfToken.php

<?php

namespace App\Http\Middleware;

use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;

class VerifyCsrfToken extends BaseVerifier
{
    /**
     * The URIs that should be excluded from CSRF verification.
     *
     * @var array
     */
    protected $except = [
        '/sns/handle-bounces',
        '/sns/handle-complains',
    ];
}

My site is HTTPS so I have correctly added the Endpoint URL in AWS console for SNS topic subscription and sent the Request Confirmation via SNS console. But I am not getting any text file I was expecting. Seems like method never executed.

Need some input on this.

Thanks in advance!

18th May, 2017

Laraveldeep left a reply on How Can I Implement My Own Custom Code Blocks? • 1 year ago

Thanks @Cronix

After googling around I think it will be simple solution for me to do what I said I won't do :)

By the way I forgot to mention that this is controlled environment so no worries. Basically I am trying to avoid HTML tags when entering text in CMS for general users. Instead use another intuitive pair of characters to denote certain things, which will be replaced later for formatting purposes. Like:

Hello {John} will be later displayed to Hello <b>John</b>
Hello [John] becomes Hello <i>John</i>

I only need very few of them, so PHP str_replace with blade {! !} seems to fit my needs instead of using full package.

So basically solved like this:

$search_chars = array('{', '}', '[', ']');
$replace_chars = array('<b>', '</b>', '<i>', '</i>');

{! str_replace($search_chars, $replace_chars, $whatever_text_in_DB) !}

All I have to do is to add items on array if I need more tags.

Laraveldeep started a new conversation How Can I Implement My Own Custom Code Blocks? • 1 year ago

Basically I need to implement custom code block to display formatting purpose, something like this on laracast (https://help.github.com/articles/basic-writing-and-formatting-syntax/)

How can I do that for text coming out from my DB?

Don't like to type HTML tags on the text and tell blade to ignore it.

Thanks!

12th December, 2016

Laraveldeep left a reply on Response Code To SNS Subscription Confirmation Not Working • 1 year ago

After some search, found something about CORS.

As suggested here http://en.vedovelli.com.br/2015/web-development/Laravel-5-1-enable-CORS/

I have created my middleware and implemented on my controller already (not sure if this is required).

Still I my controller is not receiving any message.

It seems there is no way to test this on localhost. Testing in live server makes debugging a bit tedious.

I have tried to write the whole request to a text file too for testing purpose but nothing gets written either... makes me think that controller is not receiving anything in the first place.

Really appreciate some suggestion.

Laraveldeep left a reply on Response Code To SNS Subscription Confirmation Not Working • 1 year ago

After some tests, seems like my controller is not getting any post request from SNS. Its somehow blocked.

I already have disabled CSRF token verification for this controller.

Am I missing something?

Laraveldeep left a reply on Response Code To SNS Subscription Confirmation Not Working • 1 year ago

Thanks @martinbean

I am already using aws-sdk for SES.

I have "aws/aws-sdk-php": "~3.0", in my composer.json

By the way can you please explain a bit about the code?

My old implementation is something like this:

if subscription confirmation
then go to the requested url to confirm
else
its a notification message so do something about it like mark on DB as hard bounded, soft bounced or complaint.

Really appreciate if you can share a working sample.

Thanks!

Laraveldeep started a new conversation Response Code To SNS Subscription Confirmation Not Working • 1 year ago

Hi,

I have translated my old PHP code to laravel for this. Old code is working fine.

Old code:

        $postBody = file_get_contents('php://input');
        
        $message_data = json_decode($postBody);
        
        if($message_data->Type == "SubscriptionConfirmation") {
            $confirmation_url = curl_init($message_data->SubscribeURL);
            curl_exec($confirmation_url);
        }

New Code:

        $message_data = json_decode($request->all());


        if($message_data->Type == "SubscriptionConfirmation")
        {
            $confirmation_url = curl_init($message_data->SubscribeURL);
            curl_exec($confirmation_url);
        }

I believe my code is correct and working but some other things probably I am not aware of.

I have already exempted this route from csrf token verification.

Are there any other cross domain stuffs I should be aware of?

From SNS console I am not getting any response from my site's endpoint when I send the subscription cofirmation request.

Thanks!

Laraveldeep left a reply on Add/Update Cache Control Metadata On S3 Objects • 1 year ago

Will try this later and update.

For the mean time I have solved the issue using aws-cli to update the cache control for thousands of files already uploaded.

Planning to integrate this feature on CMS I am currently working.

Thanks!

11th December, 2016

Laraveldeep started a new conversation Add/Update File Cache Control Metadata On S3 Objects • 1 year ago

Hi,

How to add/update "cache-contorl"meta data on S3 using filesystem? Documentation only mentions the metadata about size etc. https://laravel.com/docs/5.3/filesystem

Thanks!

Laraveldeep started a new conversation Nginx Gzip Question • 1 year ago

I saw a comment on nginx site configuration that gzip should be disabled of SSL to avoid BREACH attacks.

Discussion thread seems bit old as of now. Is this issue fixed?

My site is https. Can I enable gzip on SSL now?

As per google page speed test, I am getting 47/100. What else can I do to make response faster?

I already have images served from AWS Cloudfront with compression enabled.

Also I have set up the expires header like this based on the tutorial by Digital Ocean https://www.digitalocean.com/community/questions/leverage-browser-caching-for-nginx

#Expires map
map $sent_http_content_type $expires {
        default                    off;
        text/html                  epoch;
        text/css                   max;
        application/javascript     max;
        ~image/                    max;
        image/svg+xml                   max;
        application/x-font-ttf          max;
        application/x-font-truetype     max;
        application/x-font-opentype     max;
        application/font-woff           max;
        application/font-woff2          max;
        application/vnd.ms-fontobject   max;
        application/font-sfnt           max;
}

But google page speed test still suggest to leverage browser cache (no expiry defined for images).

not sure why.

This is my first nginx setup.

Really appreciate some help.

8th December, 2016

Laraveldeep left a reply on How To Get JSON Part Only Ignoring Other Text • 1 year ago

yep .. ture

after few tests... seems like I don't need to handle the extra text anymore.

Thanks!

Laraveldeep started a new conversation How To Get JSON Part Only Ignoring Other Text • 1 year ago

Hi,

If posted message is something like this:

some text
some text

{
    "value1": "someValue1",
    "value2": "someValue2"
}

How to ignore the rest of the text and just json decoded data using Laravel Request?

Have tried this but getting nothing:

$data = json_decode($request->getContent());
return $data;

Thanks!

7th December, 2016

Laraveldeep left a reply on Task Scheduler Question • 1 year ago

Ok trying to run 'php artisan` revealed some secrets.

[InvalidArgumentException]
Invalid scheduled callback event. Must be string or callable.

so it has to be closure.

Moving to closure based function solved the issue.

Laraveldeep started a new conversation Task Scheduler Question • 1 year ago

Hi,

Have added scheduler entry on crontab as stated on documentation and trying this but it doesn't seem to work.

Can I do something like this?

use App\Model;


protected function schedule(Schedule $schedule)
{
    $schedule->call($this->subFunction())->veryFiveMinutes();
}


/**** my routine tasks ****/
protected function subFunction()
{
    Model::where('some criteria')->update
    ([
        'active' => false,
    ]);
}

Thanks!

Laraveldeep left a reply on Supervisor Doesn't Auto Start • 1 year ago

Well I tried several shared init scripts but didn't work.

Solved (at least for now) by adding on reboot cron job on crontab

@reboot root /etc/init.d/supervisor start 2>&1

May not be an elegant solution.

Other suggestions welcome.

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.