squibby

squibby

Web Developer at YUDU

Member Since 3 Years Ago

Clitheroe

Experience Points
21,150
Total
Experience

3,850 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
154
Lessons
Completed
Best Reply Awards
6
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

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

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

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

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    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 Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

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

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

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

Level 5
21,150 XP
09 Jun
3 months ago

squibby left a reply on Please Help Needed - Provision Custom Server With Laravel Forge

Ok I worked it out.

Even though the deploy key was in github added by forge, they were not added to the known_hosts file. They should be added via this command: 'ssh-keyscan -H github.com >> /home/forge/.ssh/known_hosts' which i found inside the forge deploy script. For some reason even though it is run as part of the deployment script it is failing and thats why it wouldn't install.

07 Jun
3 months ago

squibby started a new conversation Please Help Needed - Provision Custom Server With Laravel Forge

Hi,

Having a headache with provisioning with forge then installing git repo.

This is what I do.

  1. Spin up my own EC2 server.
  2. Use Forge API to create a custom server in Forge and obtain a provisioning script.
  3. SSH to the server (via code) and run the provisioning script.
  4. 10 Minutes later the server is provisioned
  5. Then I try to install git repo either via api or forge UI and it just wont work. It says

Cloning into 'default'... Host key verification failed. fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

The main problem I think.. is step 3. If I manually SSH into the server myself and then run the script, after provisioning is complete I can install the git repo via the forge UI or via API. Only when I use code to SSH and run the script it wont install the repo.

I think its really weird that it wont install, because the provisioning completes. It sends me an email as normal and in Github the deploy key is set up.

I am using phpseclib to SSH into my server code below:


        // SSH to server
        $key = new RSA();
        $key->loadKey($myKeyFile);
        $ssh = new SSH2($serverIp);
            
        if(! $ssh->login('ubuntu', $key)) {
            throw new Exception('SSH exception - unable to gain access to server via SSH');
        }

        // Execute provisioning script
        $ssh->exec('the-script-obtained-from-forge-here');


This all executes and the server provisions. So what Am I doing wrong? I contacted Forge support and have been told to check my code, but i'm stuck. I cant understand why it will work when manully SSH but via phpseclib is doesn't.

If any anyone can help I will be really grateful.

Thanks.

02 Jun
3 months ago

squibby started a new conversation How To Trigger A Webhook After Forge Provisioning Complete.

Hi,

I am creating a custom server via forge api. The api allows a post provisioning forge recipe to be triggered once provisioning is complete.

What i want to do is.. write a recipe which once the server is provisioned, sends a webhook back to my application and informs me that the provisioning is complete, and also send along the forge ID of the server.

Is there any way to gather forge specific data about the server which I can send somewhere?

Thanks.

06 Jan
8 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
8 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
9 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 
        });
    }

The new environment variables if prepended to the file override the current ones. If they are appended it doesn't seem to take priority. This all may have been fixed as a feature in newer versions of Dusk. I am running an older version.

28 Sep
11 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
1 year 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
1 year 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
1 year 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
1 year 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
1 year 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

If you struggle, open a new question and can solve it from there.

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. So anyone else make sure no error that will allow npm run dev to work but not npm run production.

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
2 years 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
2 years 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
2 years 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', $fashionMan); 
        });
    }


18 Sep
2 years 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