squibby

squibby

Member Since 3 Years Ago

Clitheroe

Web Developer at YUDU

Experience Points 20,840
Experience Level 5

4,160 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 152
Lessons
Completed
Best Reply Awards 6
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

06 Jan
3 months ago

squibby left a reply on How To Start Out With Automated Scripted Deployment? Help

After looking at this post: https://laracasts.com/discuss/channels/servers/using-aws-elastic-beanstalk I was lead to believe that forge and beanstalk wouldn't work together.

Forge does handle cron and queues, really well and other useful things which allow management of servers/sites easily. So i guess, yes as I am using forge heavily I would like to continue.

squibby left a reply on How To Start Out With Automated Scripted Deployment? Help

Thanks for your info.

Currently I am setting everything up manually. Then for my Ec2 I am provisioning with a custom server provisioning script via Laravel forge. Laravel forge also handles the code deployments, queues, cron and everything else.

From what I have looked at, elastic beanstalk wont work with forge unless Im mistaken. I have spent a few days playing around with aws cloud formations, I think I should be able to script out the architecture exactly as I set it out manually using formations. It is pretty complex though so will take me a while to get my head around all the settings.

If that goes to plan, I will then look at perhaps using forge apis, to hook into the ec2s and provision etc.

Question about beanstalk though.. If using beanstalk do you stull have access to all the underlying servers, rds etc or is it all contained in 1. Beanstalk sounds like a nice solution but i'm not sure how I could make it work with my current setup.

02 Jan
3 months ago

squibby started a new conversation How To Start Out With Automated Scripted Deployment? Help

Hi,

I have been working on a large Laravel project which is deployed via AWS. It currently has multiple EC2, load balancers, VPC, s3 and more as part of my deployment process. My deployments are all manual at the moment which can be time consuming as there are multiple 3rd party services and apis which all need to be connected also.

I want and need to be able to automate all of this as I will be deploying multiple instances of the project as required. So....

What is the best way to automate / speed up my deployment process? I am looking for some general advice here. Or some links to some places I can investigate. I am capable of creating complex laravel applications but the automated deployment side of things is where I am not yet educated.

I have seen but don't fully understand - docker, aws cloud formations, ansible and other but not sure which direction to go or this is what is suitable.

My ultimate goal is to be able to build a small laravel app which can be used to trigger the deployment / scripts which auto build my infrastructure and set up environment the same each time.

If anyone has some advice i would be most appreciative. Many Thanks.

27 Nov
4 months ago

squibby left a reply on How To Change Env Variable / Config In Dusk Test?

I figured out a way to make this work. I had to directly alter the .env prior to any test being run.

I added the following method to my DuskTestCase.php

 /**
     * Overrides any .env files for dusk tests
     *
     * @param array $variables
     */
    protected function override($variables = [])
    {
        $path = '.env';

        if (file_exists($path)) {

            // The environment variables to prepend
            $prepend = '';

            // Convert all new parameters to expected format
            foreach($variables as $key => $value)
            {
                $prepend .= $key . '="' . $value . '"' . PHP_EOL;
            }

            // Grab original .env file contents
            $original = file_get_contents($path);

            // Write all to .env file for dusk test
            file_put_contents($path, $prepend . $original);
        } 

Then call in any dusk test method prior to using $this->browse like this:


public function test_something(){

        // Disable feature
        $this->override([ "ENABLE_SOME_FEATURE" => "false" ]);

        $this->browse(function (Browser $browser){
                   $browser->resize(1200, 2000)
                                     ->loginAs(User::find(1))
                                    // etc 
        });
    }
28 Sep
6 months ago

squibby left a reply on How To Change Env Variable / Config In Dusk Test?

@Sti3bas No solution as yet. I think it can't be changed from within the test. Perhaps will need to make some way to select different dusk .env file depending on the test....

The only way I can do now, is manually change the .env file for each group of tests, but its not ideal.

20 Aug
8 months ago

squibby left a reply on How To Change Env Variable / Config In Dusk Test?

No, I already have a separate local dusk env file. I need to change the env variable for different tests. For example I have a section on the site which I only want to enable for certain deployments. I need to ensure that items are definitley not shown for those occasions.

squibby started a new conversation How To Change Env Variable / Config In Dusk Test?

I have a .env variable link to a Laravel config file which toggles certain section in my site. In Dusk testing I want to test that certain functionality is shown / hidden depending on this state.

How to set the config / or update dusk .env variable on each test?

I have tried Config::set() but it doesn't seem to work. Has anyone else done this before?

Thanks.

04 Aug
8 months ago

squibby left a reply on A Blank Page When I Access /horizon

Have you published horizon assets?

php artisan vendor:publish --provider="Laravel\Horizon\HorizonServiceProvider"

squibby left a reply on Need Help With My Currency Converter

You are not passing $query to your view, but in your view are using $query.

28 Jul
8 months ago

squibby left a reply on Advice Required For Testing Using Selenium In Laravel 5.2

Thats a pretty cool workaround. Are you still able to run migrations/transactions etc from the 5.6 project?

25 Jul
9 months ago

squibby left a reply on Mailgun - Send Hundreds Of Thousands Of Emails

I have done this. I used Bogardo Mailgun package and then used batch sending. You can send 1000 emails per batch, so in your case would need 100 jobs instead of 100,000. This also helps with the mailgun api throttling of 300 requests/minute. Just chunk your collection into blocks of 1000.

Using batch you can still customize the headers and individual mail content which is useful.

So yeh have a look a bogardo mailgun should make it easier i think. Only problem i had is that is doesn't support laravel mail class so I had to write the emails in html instead of taking advantage of markdown mail.

10 Jul
9 months ago

squibby left a reply on How To Add Custom Headers To Notification Emails?

Can you not use a Mail class instead of notification like in my answer? You can do it that way. Look on this page for info:

https://laravel.com/docs/5.6/mail#customizing-the-swiftmailer-message

28 Mar
1 year ago

squibby left a reply on How To Add A Custom Class To A Tag Using Mews/purifier

Yes thanks, I think thats right. This is for stripping things out rather than adding them in. I have managed to do it another way instead now.

I have just placed a listener on my input text area and add the class to any links. it does the trick for my purposes.

26 Mar
1 year ago

squibby started a new conversation How To Add A Custom Class To A Tag Using Mews/purifier

Hi,

I am using mews/purifer to filter user inputted html. Eventually the html will appear in a separate app and I want to ensure that any links are given an external class like show below.

Using this package how can I automatically add a class to each user inputted link??

So.. User inputs something like:

<a href="http://somewhere.com">Go Somewhere</a>

I would like to to update it to be:

<a class="external"  href="http://somewhere.com">Go Somewhere</a>

Thanks for looking.

20 Mar
1 year ago

squibby left a reply on How To Make The Laravel-mix Project Work When Copying To Another Pc

have you transferred the whole project to another computer? Or just the assets? You will need the webpack file.

squibby left a reply on Dusk. Assert Text Is Not Visible When Scrolled Out Of View In Div

Im not sure but, this could be solved with ensuring the latest chrome driver is installed. I had problem with scrolling before and updating the chrome driver fixed it. Which version of dusk are you using? If you cant update to latest version you can manually put the file in the bin directory. Maybe this will help you.

squibby left a reply on Display Data In Data Table

More information here https://github.com/yajra/laravel-datatables/issues/594

I think the ->get() part is added automatically by the package. At least for the version that is being used here. It is a bit confusing.

19 Mar
1 year ago

squibby left a reply on Display Data In Data Table

Try removing the ->get() from query.

24 Jan
1 year ago

squibby left a reply on Export To Excel

Use this package: https://github.com/Maatwebsite/Laravel-Excel

I use for all csv/excel import/export tasks it is very good.

22 Jan
1 year ago

squibby left a reply on Laravel Mix Error Problem For Production

I was able to locate a small error in my source code and after fixing that the error was gone.

squibby started a new conversation Laravel Mix Error Problem For Production

I have been using Laravel mix for a while now and had no issues. Only recently when i came to run npm run production did i get this issue:

Whoops! We had trouble minifying "public/build/js/custom-scripts.js". Perhaps you need to use mix.babel() instead?

So how to use mix.babel()??

Do i need to download it separately and config somewhere? Has anyone else had this issue and able to point me in right direction?

08 Dec
1 year ago

squibby left a reply on I Need Help Mailgun

which email are you sending to? I think if you are using the sandbox it will only send to upto 5 address you need to specify in mailgun dashboard.

squibby left a reply on Hide Admin User In View

Remove the admin user from the collection before you pass it to the view.

24 Nov
1 year ago

squibby left a reply on Accessing Data Inside Queue::after()

I would like to do this too. Anyone done this?

21 Nov
1 year ago

squibby left a reply on Mac Shutdown During Tests. Why?

Setting processIsolation="true" in the phpunit.xml file seems to have fixed this issue.

07 Nov
1 year ago

squibby left a reply on Error When Hosting A Laravel Site

Have you installed all composer dependencies etc?

squibby left a reply on How To Create Custom API Guard.

@ssi-anik that helped me to find a suitable solution. Thanks.

31 Oct
1 year ago

squibby left a reply on How To Create Custom API Guard.

Thanks. I have looked at passport, but its seems very complicated for what I am doing. If i was starting from scratch I would consider delving into it. But i already have everything built out. I just need to check a different database table for tokens and expiry. I think I will try and build a new guard like api:custom and try and customise it to my requirements.

30 Oct
1 year ago

squibby started a new conversation How To Create Custom API Guard.

I have built an API with Laravel using built in api token authentication. This is working as expected and uses the api_token column on my user model.

I have been tasked with supporting multiple api tokens with expiry by having a separate related tokens table which is linked to the user.

I would like to somehow instead of using the auth:api method of authenticating, use something which will check if a user token exists and is not expired form the token table.

I think i need to write a new guard. But im not so sure. How and where can I specify the new logic.??

If any one could help out I would really appreciate. Do i need a new guard or can I override a method somewhere which handles the way the user is authenticated?

Thanks.

17 Oct
1 year ago

squibby left a reply on Jobs Processed, But Not Doing Anything

I have had this before and couldn't understand why it wouldnt log. Just stop the queue worker, and then check the logs the log info should be there. To check try doing something other than log in your job. E.g update a record or something. You will see it should work perfectly.

03 Oct
1 year ago

squibby left a reply on Mac Shutdown During Tests. Why?

Ok so it happened again and this time I checked it was error 62. Which is 'Watchdog timer detected unresponsive application, restarting the system' which is consistent with what has been happening.

squibby left a reply on Mac Shutdown During Tests. Why?

Thanks thats useful. I had a look and i see "Previous Shutdown cause: -128" which is unknown.

squibby started a new conversation Mac Shutdown During Tests. Why?

Sometimes when running my phpunit tests my Mac Mini shuts down without warning. This can also happen when running dusk test as well. Without warning I get a black screen and then it shuts down and restarts by itself.

Has this happened to anyone else? Where can I look to diagnose why this is happening?

Its getting really frustrating, it happens about 20% of the time I run any tests.

Thanks.

26 Sep
1 year ago

squibby left a reply on Database Migrations And Deploying To A To Load-balanced Group.

I use Laravel forge to install app code on to each server which is linked to Github repo. I then SSH into one of them, and run the initial migrations and seeds which sets up my database in RDS. I like to check everything is all working.

I highly recommend using Laravel forge. It will you a lot of time in getting everything set up. On each code deployment from forge you can trigger post deployment command, php artisan migrate can be one of them, or you can remove it depending on the server.

I generally do all the setup on 1 machine and then move onto the other. I get all the Elastic load balancer in AWS (not in forge) working first though before I install all the app code.

You probably don't need to SSH to any server if you let Forge handle everything, but you can add keys in forge which makes access easy with forge user.

If you use Laravel forge to provision your load balancer on an EC2 things would become even easier for you. I prefer to keep that separate though, as I found I couldn't load balance servers in different availability zones which was what I wanted for high availability.

squibby left a reply on Retry Failed Jobs By Queue Name?

can you specify --queue flag? I know can do this for workers.

php artisan queue:work --tries =3 --queue=default,whatever

squibby left a reply on Database Migrations And Deploying To A To Load-balanced Group.

Can you not just SSH into 1 machine and run the migrations from there. Thats what I do, running load balanced EC2 and a separate multi-AZ RDS for the database.

25 Sep
1 year ago

squibby left a reply on Help Laravel Problem With Chartjs

  1. Is that all you have in your controller? You will need to actually pass the $popular_posts results to the view.
  2. Where is your js? If it is in the view, then you can use blade syntax {{ }} to put any data in there you like.

squibby left a reply on How To Load Excel File From Hosting Storage

I think you need to specify the storage path. So something like:

storage_path($file->file_url)

squibby left a reply on Laravel Mssql Named Instance.

Clear cached variables and try again.

php artisan config:clear

Might do the trick.

squibby left a reply on Forge Not Deploying Code Anymore

Try refreshing the github tokens? This might fix it.

21 Sep
1 year ago

squibby left a reply on API

I dont think you would need an api as such. When processing the web form, before you send the email can you not just insert the record into a table on your database?

Is the system you want to insert the email, the same system that handles the web form?

squibby started a new conversation API Advice Required Please.

Hi,

I currently use the auth:api middleware on some basic API routes for my application. Using a 60 character api_token on my User model I can make requests by appending the api_token in a request query string and everything works ok. I use this to deliver some simple json to a basic web app external to Laravel.

This is fine for basic purposes but I would like to expose many more routes for the API which give someone (a high level admin) much more control over the backend. e.g create/edit/delete users, groups and other entities within the system. Basically I would like to flesh it out to be a fully functional API that can be used to control backend tasks from for example a clients HR system.

I would only like specific users to be able to use the full API and normal users would have basic access like before.

So... what would be the best way forward. I have thought about creating a 'full API access' permission for specific Users which I can switch on in my backend and then generate a Secret Key. Using that secret key together with the api_token, full access API users could pass some kind of token in the request headers which would identify them as someone who can perform actions on specific routes. Anyone trying to access these routes without a valid token would be denied. I could create a middleware and place it on the api route group.

Now... I have seen Laravel Passport, is this something I should be using to do these types of task. Im willing to implement that if thats recommended as a good solution. I have not delved too far down that path yet though, as the api_token and auth:api have been useful to me so far.

So... please if anyone has any advice in the best way forward in terms of the API i would like to build please shed some light. I would greatly appreciate.

Thanks in advance.

squibby left a reply on Displaying AJAX Response

In your ajax function console.log the html response. What is it returning and in what format. If you are getting a 200 its passing something back. Maybe need to set the expected response explicitly to html in ajax function.

20 Sep
1 year ago

squibby left a reply on Does Laravel Database Queue Driver Work Across Multiple Servers With Multiple Queue Workers?

Thanks, I thought so as well. I need to know for sure though if the database driver is up for the job across multiple servers. I have a separate database(AWS RDS) so it is not on the same server as the app code. I'm guessing the jobs/rows will be locked if a queue worker is working on it.

I'm assuming using the database as queue driver will have a heavy load on the database and therefore using something like Redis would be preferable.

If anyone has any more information regarding using database queue driver across multiple app servers, I would appreciate.

Thanks

19 Sep
1 year ago

squibby left a reply on How Do I Put A Variable Here?

Because it is in a function closure so you need to use variable injection.

  public function maincategory()

    $fashionMan = 'fashion man';

    {
        return $this->builder->whereHas('maincategories', function ($query) use ($fashionMan) {
            $query->where('main_cat_name', 'Fashion Man'); 
        });
    }


18 Sep
1 year ago

squibby started a new conversation Does Laravel Database Queue Driver Work Across Multiple Servers With Multiple Queue Workers?

Hi,

I am moving towards building my Applications across load balanced multi-server setups. Previously on a single server I would use the database driver for queued jobs and found it to work fine for my purposes.

My question is, if I am starting queue workers on 2 app servers (managed by Laravel Forge) will everything work as it should or will there be issues that cannot be handled by using the database driver. (For example the jobs being processed multiple times or not at all when 2 workers try to process the same job?)

Is the database driver suitable, or I have I outgrown this driver and now need to use something like Redis?

I'm a bit unsure of the best way forward here, hopefully someone has done this and can offer some advice.

Thanks

14 Sep
1 year ago

squibby left a reply on Setting AWS Availability Zone?

If creating server in forge there is no way to control which availability zones they are created in. The best way and to have more control is to manually setup EC2 server with Ubuntu from AWS control panel. This way you can set up in your own VPC and specify which subnet and zones the servers will sit in.

Then use laravel custom VPS option to obtain code for provisioning the server. Logging into the EC2 manually and running this code will provision for Laravel and and then Forge can be used as normal.

I then manually create an elastic load balancer in AWS and setup for https etc.

I don't provision a server as a Load balancer in forge as it only allows load balancing to servers in the same availability zone.

squibby left a reply on How To Redirect Http To Https When Behind Load Balancer

So instead of setting up a redirect in the nginx.conf file, I set it up in /etc/nginx/sites-enabled/default file.

if($http_x_forwarded_proto = 'http'){
    return 301 https://mydomain.com$request_uri
}

This seemed to do what I wanted and force everything over to https.

Laravel forge recommends to delete the 'default' site and create a site with the domain name. I have done this previously and it works fine. However when doing this the site is no longer available via the ip address only in the browser. It only works after pointing DNS to the server IP and then it works. This is fine and has suited me for single server deployments.

Now I have 2 servers behind a load balancer, I am finding that the AWS elastic load balancer health checks fail if I dont use 'default site'. The reason I assume is that when the Load balancer pings the ip it doesnt receive a 200 response and assumes the servers are not there.

So.... is it cool to keep the app running in the 'default' site... or should I be doing it in a different way.

Thanks.

13 Sep
1 year ago

squibby started a new conversation How To Redirect Http To Https When Behind Load Balancer

I have setup up 2 custom EC2 severs on AWS then used forge to provision them. I have setup elastic load balancer on AWS and successfully balance the traffic over http and https to the 2 app servers.

How can I force the browser to https if http is being used. Do I need to manually login and setup some kind of redirect? I have tried updating the nginx.conf file with a redirect but everything broke.

Another issue is, usually if I provision a server from within forge itself (not custom vps) I then name my site the name of the url and everything works out. Using the Elastic load balancer I can only get everything to work if use 'default' as the site name. Is there any way to change this? Or does it not matter if I just use 'default' so long as it works.

Is the fideloper/proxy package, something that will fix these issues?

Has anybody any experience of performing such a task. Would greatly appreciate some info.

Thanks