shawnyv

shawnyv

Member Since 5 Years Ago

Experience Points 42,090
Experience Level 9

2,910 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 353
Lessons
Completed
Best Reply Awards 2
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.

25 May
3 weeks ago

shawnyv left a reply on Help With Nginx & Serving Internal App

Okay - looks like a lot of this was me being stupid.

I think I was forgetting to symlink the available-sites file correctly to enabled-sites, and didn't have the correct permissions in place.

Anyway - thanks so much for helping put me on the right path all!

Shawn

shawnyv left a reply on Help With Nginx & Serving Internal App

I realized I was wrong above - the file it's downloading is the index.php file from the public directory.

The server was created for me, and I was given non-root access (I've got to use sudo to do anything in it).

Could this whole thing be a permissions issue?

I've set the laravel application folder to 755.

This is my server conf file:

''' server { listen 80 default_server; listen [::]:80 default_server;

server_name myprettyurl.com; root /var/www/mysite/public; index index.html index.htm index.php;

location / { try_files $uri $uri/ /index.php?$query_string; }

error_log  /var/log/nginx/default-error.log error;

error_page 404 /index.php;

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
}

location ~ /\.{
    deny all;
}

} '''

That's in my /etc/nginx/sites-enabled and /etc/nginx/sites-available directories

I've got php7.2-fpm installed, as well.

This is all so frustrating - it's getting to the index.php page, but just forcing download instead of rendering.

Thanks for any additional insight!

shawnyv left a reply on Help With Nginx & Serving Internal App

Hi @burlresearch,

I've got the php7.2-fpm in place, but it doesn't seem to be doing anything right now. I've set the /etc/hosts on my client machine, but it's just downloading the artisan file as well. Same thing as when I hit the server IP.

@keevitaja - thanks for your answer - I don't have any fastcgi in my config, I"ll have to give that a shot.

Thanks to everybody for their help on this - server side stuff is definitely not my forte, and it's making me appreciate Forge so much more!

Shawn

24 May
3 weeks ago

shawnyv left a reply on Help With Nginx & Serving Internal App

Thanks so much for your help @burlresearch!

I'm closer, but still missing something... The pretty address still isn't working, but when I go to the IP it's now downloading the artisan file.

Still showing nothing in the browser though.

Any additional help would be super appreciated!

shawnyv started a new conversation Help With Nginx & Serving Internal App

Hi all,

I'm trying to get a laravel app set up for a client on their internal network (no access from outside world).

This is the first time I've had to do any server management stuff outside Forge, and it definitely paints a compelling picture why I never want to work without forge!

I've followed this tutorial to get my app set up on the new server, and it's worked beautifully, EXCEPT that I can't figure out how to actually get it to load in the browser (all my commands are working fine though).

https://medium.com/@grmcameron/deploying-your-laravel-web-app-1faaa66f3302

I'm sure there's something simple I'm missing between my sites-available files (and maybe the /etc/hosts ?), but I can't for the life of me figure it out, and all my googling to this point hasn't helped.

I'd like the site to load either with the server IP, OR with an alias that can be accessed by any connection that has permissions to see it (IE me when I'm VPN'd into the remote server).

EG: I'd love either http://123.45.67 or http://my_pretty_name.com to work (without having to link my_pretty_name.com, of course)

I've tried various combinations of server_names in the available-sites file(s) to no avail... EG:

''' listen 80 default_server; listen [::]:80 default_server;

    root /var/www/mySiteDir/public;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html index.php;

    #server_name _;
    server_name mySiteIp;

'''

Any help would be much appreciated

10 Apr
2 months ago

shawnyv left a reply on Tools / IDE Plugins To Identify N+1 Issues?

Thanks all - I'm already using Telescope in my newer projects, and Laravel Debugbar in older ones (and before that, Clockwork).

Ideally I'm looking for a solution like a code inspection tool or test coverage tool, but that specifically touches on N+1 issues.

It's mostly a piece of mind thing - Just like I can use the Reformat Code option in PhpStorm to get the code style consistent across all files, and the Inspect Code tool to find areas where I've introduced other code smells, it'd be great to have an automatic N+1 finder that doesn't require me to hydrate & manually visit every route.

shawnyv started a new conversation Tools / IDE Plugins To Identify N+1 Issues?

Hi all,

Was wondering if there are any tools or PhpStorm plugins for the Laravel / Blade ecosystem that can identify possible N+1 issues.

I ran into a situation the other day where I found some code being called from the view (A), that hit the model (B), which had a call to another relationship (C), but when the collection was instantiated in the controller (D) it didn't eager load the call being made in (C), and realized that's probably occurring in quite a few of my existing projects.

Thanks for any suggestions!

Shawn

27 Mar
2 months ago

shawnyv left a reply on Possible To Use Multiple Mailgun Domains?

@WILK_RANDALL - Wonderful, thanks for the heads up!

shawnyv started a new conversation Possible To Use Multiple Mailgun Domains?

Hi all!

I've got an application where I need to use different mail domains for different tasks (IE: task 1 uses "mg.domain1.com" and task2 uses "mg.domain2.com")

Is there an easier way to handle this than wrapping each mailable requirement within code like this:

$starting_domain = config('services.mailgun.domain');
        config()->set('services.mailgun.domain', 'mg.domain2.com');
        // ...Code here
        config()->set('services.mailgun.domain',$starting_domain);

Thanks for any help!

28 Feb
3 months ago

shawnyv left a reply on Database Error

Can you connect to the database elsewhere? Have you tried restarting the database?

05 Feb
4 months ago

shawnyv started a new conversation Sequel Pro Mojave Crash (Fix / Workaround Included)

Just wanted to share this, as it's been a source of frustration for the past couple months for me, and I wish I'd known this one earlier.

If you're working with Sequel Pro in Mojave, and close a second tab, the program crashes. However, you can get around this pretty simply.

It only seems to crash when the tab is in the 2nd or deeper position. So if you move the tab you want to close to be leftmost, and then close it, it doesn't crash the program.

Only realized this today, but I haven't had a crash with it yet. Will keep trying and update if it stops working, but for now, hopefully that'll help somebody else keep their Sequel Pro from crashing way too often!

31 Dec
5 months ago

shawnyv left a reply on Problematic, Non-conventional Project

If there is a decent test suite, you should be able to start refactoring without too much issue. If not, you'll have to do regression test creation prior to starting your refactors, and lots of manual checking.

That being said though - it's always tempting to jump in and "fix" things... Just remember that when you got brought in, the system was working well enough for the client to be happy-ish with it, and your core job is to extend the functionality, not necessarily to "fix" it until you can demonstrate to your boss why those fixes will add value in the long term.

Also remember that being new to the framework, the code you write today will be the "ugly, broken code" of somebody else (or yourself) a year down the road... I say that as I'm going through laravel code I wrote 4 years ago and cringing at how stupid I was.... :D

shawnyv left a reply on Is There A Better/shorter Way To Create Column Filters?

After doing it once, I moved to using DataTables and Yadcf for any tabular results section requiring filters. It brings its own challenges (Load all results to page first, or load via ajax? If the latter, its ugly to include html in the cells), but the advanced filtering is well worth the tradeoff IMO.

17 Aug
10 months ago

shawnyv left a reply on My Tests Run Super Slow

Have you disabled Xdebug on your local machine?

That big a discrepancy suggests to me that you're running with xdebug enabled, which creates a HUGE slowdown.

04 Apr
1 year ago

shawnyv started a new conversation Xdebug Issues After Homebrew Update?

Hi all,

I made the mistake of doing a brew upgrade today, not realizing that they'd dramatically changed the way that php versions & extensions were handled.

I've reinstalled xdebug via PECL (as is apparently the expectation from the homebrew folks now), and got my xdebug working within PHPStorm, but it's not working from the command line / while running tests any more. Has anybody else run into this, and have any tips for me on how to get it up and running again?

Thanks!

21 Mar
1 year ago

shawnyv left a reply on Running All Tests That Cover A Method

I often do something similar, but unfortunately this isn't the most organized testing code-base.... 600+ tests, about half of them relatively expensive integration tests, and when I look at coverage reports some of the most important methods are being hit by a dozen or more tests across 5-6 different suites, the suites themselves sometimes having dozens of tests in them that take quite a while to run.

I was hoping there was a simple PHPUnit flag I was missing, or easily downloadable package that I hadn't been exposed to yet... Apparently I live in perpetual optimism, haha.

Thanks for the reply!

shawnyv started a new conversation Running All Tests That Cover A Method

Hi all,

I'm feeling a little late to the game in starting to get a lot more serious about my code coverage, as well as mutation testing within my projects.

One thing I'm realizing would be really awesome is a command or flag when running the test suite that runs all of the tests which cover a method.

Right now I can look at the coverage report generated by xdebug, go into each class, and when hovering over lines of code it will show me which tests cover that code ... But it'd be awesome to be able to pass that method or class->method into a flag when running phpunit so that all tests covering it were run.

That'd make it a lot easier to refactor without having to run my whole test suite, or to dramatically re-arrange my existing tests.

Is there an easy way to do this?

Thanks!

12 Dec
1 year ago

shawnyv started a new conversation Testing Accepting Form Input From Off-site?

Hi all,

Is there an easy way to fake an off-site form submission? I want to test that I've successfully disabled the middleware just for a single route, and that the request coming from off-site works as expected once the input has been received.

Thanks!

11 Dec
1 year ago

shawnyv left a reply on "It Is Unsafe To Run Dusk In Production." Error When Trying To Deploy

Thanks @jaewun for the hat-tip on the forge deployment script! I just assumed the forge default settings would be optimized to include this.

You saved me from having to manually remember to comment out the dont-discover section every time I wanted to run Dusk!!!

02 Dec
1 year ago

shawnyv left a reply on Help With Querying A Model

You need to complete the query by using the get().

so

$sb = \App\SB::where('token', $token)->get();
12 Oct
1 year ago

shawnyv left a reply on Multiple Databases And Testing

Just one point I wanted to bring up that I didn't see elsewhere - there is a fabulous property that we can include in tests where we're using DatabaseTransactions called $connectionsToTransact.

So we can do ``` protected $connectionsToTransact = ['database1','database2'];


In order to ensure our testing is able to hit both databases without leaving anything behind.  The names come from the database.php config file.  
29 Sep
1 year ago

shawnyv left a reply on Case Sensitivity Checking (OSX)

Thanks - I didn't even think about the mess I was getting myself into by picking the wrong formatting option when I wiped the machine the last time. :)

shawnyv started a new conversation Case Sensitivity Checking (OSX)

Hi all,

I'm running into an issue where I've inadvertently introduced some case sensitivity mismatches in a large chunk of code, which is currently running on a Windows server in prod.

I want to move it to a Forge / Digitalocean combo, but when I ran a test I found there were some instances of case insensitivity that Windows (and apparently, my OSX nginx) didn't catch (ie '[email protected]' vs. '[email protected]')

Is there an easy way to enable that kind of checking on my OSX dev env so that my tests can catch it?

Thanks!

Shawn

21 Aug
1 year ago

shawnyv started a new conversation Storing Calculation Formula In Database?

Hi all,

I'm sure there's a super simple answer for this, but it's baffling me at the moment. Simply put, how do I reference variables / formula in code, which is stored in a database?

Background Info:

I'm creating a scored survey, and I want to be able to use different calculations on different questions in order to give users a score at the end.

EG: Question 1 will be on a scale from 1-10, and the score will be calculated as "Score * 10".

Question 2 will give a negative score, in the format (Score - 10) * 10

I'd like to be able to attach a "scoring_id" to each question, and define the scoring pattern in a database table, but once I do that I'm not sure how to put it to use within my code.

Any help on this would be very appreciated!

Thanks

25 Mar
2 years ago

shawnyv left a reply on Multiple Databases And Testing

Thanks for sharing this - I was just about to post a thread asking about this very topic.

Will try this method first - it looks like you've saved me a lot of time! :)

15 Jan
2 years ago

shawnyv started a new conversation Mail - Test Mail Not Sent To Specific User In Laravel 5.3

Hi all,

I've just started mocking my Mail asserts, and using the fantastic 5.3 features to wrap it behind the Mail class.

I'm loving the ability to assert MailSentTo($user, $mail), but was wondering how to test that a mail was not sent to a specific user.

I've got a daily email reminder that should go out to users based on activity - I want to test that it did get sent to some users, but not to others.

I couldn't find an "AssertNotSentTo" method, just the "AssertNotSent" method. I'm expecting the mail to be sent, i just want to make sure it's only sent to the users it should go to.

Is there a simple method I'm missing, or an easy way to add this assertion?

Thanks!

15 Nov
2 years ago

shawnyv left a reply on Hosting 2 Sites On Same Server?

They're running on a local server on site utilizing Xampp (Not my first or third choice). Only about a dozen users for each service, and strictly limited to the internal network.

shawnyv left a reply on Hosting 2 Sites On Same Server?

Hi Snapey,

Yes, that's exactly correct. My database connection settings look the same in both sites, and in the .env file the only change comes to the DB_DATABASE variable (the host and password and username remain the same):

'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('DB_DATABASE', 'forge'),
            'username'  => env('DB_USERNAME', 'forge'),
            'password'  => env('DB_PASSWORD', ''),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],

shawnyv started a new conversation Hosting 2 Sites On Same Server?

Hi all,

I'm running into an issue where I have 2 laravel sites (both Laravel 5.2) on the same server.

It looks like there's some contamination of the config settings - IE one site's error logs shows that its trying to access the 2nd sites database.

I've tried setting an artisan command to clear the config cache at the start of every page load, and ensured my cache prefix values are distinct, but to no avail.

Can anybody help me with this?

Thanks!

12 Nov
2 years ago

shawnyv started a new conversation Database Backup (Changes Only)?

Hi all,

I'm running a few small apps and really liking the database backup packages available for Laravel (used both the spatie & backup-manager ones).

The default behavior in them seems to be to do a full database dump, and then to archive the dump & store wherever you choose (S3 for me).

I'm currently working on a project that has a lot of data (2 GB+ and growing by 100k+ rows daily), and I don't really like the "do a full DB dump, compress and store" method - is there a package that makes it easy to just grab the changes since the last backup, compress, and store them instead?

Thanks for any insights!

10 Nov
2 years ago

shawnyv started a new conversation Multiple Sites On Server Issue

Hi all,

I'm stumped by this, and hoping I can get some help. I have 2 sites running on a XAMPP server, and it appears that in some instances, the .env variables are getting mixed up.

EG: Site A uses "email" as the core field in the users table, site B uses "username" for the same purpose. Occasionally, I get an error that the query can't complete for site A because "email" doesn't exist in the database it's looking at.

I've received other error messages where it's explicitly naming the wrong database to be looking for a value in.

This seems to go away on a reload, but I'm not sure why it's happening in the first place. Can anybody help me out here?

Thanks!

30 Jul
2 years ago

shawnyv left a reply on Removing Variables From URL In Middleware?

Only stripping out referrer would look like this (great catch @RoboRobok !!:

public function handle($request, Closure $next)
    {
        if($request->has('ref'))
        {
            $path = $this->strip_referrer_from_path($request);
            $existing_cookie = $request->cookie('referrer');
            if(is_null($existing_cookie))
            {
                $cookieLength = 60*24*env('COOKIE_DAYS');
                $referrer = $request->input('ref');
                return redirect()->to($path)->withCookie('referrer',$referrer,$cookieLength);
            }
            return redirect()->to($path);
        }

        return $next($request);
    }

    /**
     * @return string
     */
    public function strip_referrer_from_path($request)
    {
        $path = $request->path();
        $inputString = '?';
        $inputs = $request->input();
        foreach ($inputs as $key => $value)
        {
            if ($key != 'ref')
            {
                $inputString .= $key . "=" . $value . '&';
            }
        }
        $path .= $inputString;

        return $path;
    }

shawnyv left a reply on Removing Variables From URL In Middleware?

That's a good point, but this application won't be utilizing GET requests w/ URL data - I either set up a restful-style path, a PUT + form, or javascript / AJAX for anything that would require an in URL data feed.

So for the app I'm developing it won't be an issue, though of course my code could be amended to grab all the inputs, strip out the referrer specifically, then redirect with the non-referrer pasted back on.

Thanks for your thoughtful replies!

shawnyv left a reply on Removing Variables From URL In Middleware?

What I needed was way easier than I thought - @RoboRobok , you were exactly right, all I really needed to do was grab the path from the request, then do a redirect in the case there was a reference there.

For future reference, and in case anybody is as dumb as me in the future, here's the code for my affiliate_code grabbing middleware that returns the user to a "clean" url (it was getting the path & redirecting to that path that eluded me the first time).

public function handle($request, Closure $next)
    {
        if($request->has('ref'))
        {
            $path = $request->path();
            $existing_cookie = $request->cookie('referrer');
            if(is_null($existing_cookie))
            {
                $cookieLength = 60*24*env('COOKIE_DAYS');
                $referrer = $request->input('ref');
                return redirect()->to($path)->withCookie('referrer',$referrer,$cookieLength);
            }
            return redirect()->to($path);
        }

        return $next($request);
    }

shawnyv left a reply on Removing Variables From URL In Middleware?

Thanks for the help!

My apologies for misunderstanding your earlier point - When you said "or just to behave like they were never there, but keep them", I assumed you meant to keep the value available to the system, not keep it in the URL.

I'm sure this will get me where I need to be - thanks!

shawnyv left a reply on Removing Variables From URL In Middleware?

It's mostly an aesthetic thing - Especially if I've got affiliates using link shorteners, it would be nice if the page the end user landed on didn't have the giant ugly URL string that screamed "This is an affiliate link, guys!" :)

@jimmck , I'm not sure if I can unset them - I tried unset($request->input('ref')) and got an error, and then tried $request->forget('ref'), but that didn't work either.

shawnyv left a reply on Removing Variables From URL In Middleware?

I don't really have a preference - It's to grab an affiliate ID, so once I've set it into a cookie, I don't need it any more.

My only constraint is that I want it to be set up as a Middleware I have in my Web grouping, so that no matter what valid page the user is sent to, the cookie gets set.

Thanks in advance for your help!

Shawn

shawnyv started a new conversation Removing Variables From URL In Middleware?

Is it possible to receive a URL variable (www.mysite.com/?ref=abc), and strip off the variable in the middleware so that the final page the user ends up on is just www.mysite.com/

I know I can grab the value of the variable with $request->input('ref')

But I have no idea how to tell it to strip that variable off the URL before passing the request along.

Any help would be much appreciated!

Thanks

28 Jul
2 years ago

shawnyv started a new conversation Overwriting Default Integration Testing Parameters?

Hi all,

Watching Jeff's video on working on a Selenium adapter was very cool, especially to see how (relatively) easy it was to create a nice, fluent syntax for testing.

In that video, he was taking methods from the Selenium class, and creating behavior that better fit the new names.

Where would we look to overwrite the basic integration tests, or to add our own methods? IE one of the things that I really need is an easy way to be able to do selections based on id, not name (so I want to be able to pass an ID or other selector to 'check', 'type',).

Can anybody point me in the right direction for that?

Thanks!

18 Jul
2 years ago

shawnyv left a reply on Null Coalesce Question

Beautiful - thanks so much for that!

shawnyv started a new conversation Null Coalesce Question

Hi all,

I'm wondering if there's functionality like the null coalesce, but for defining arrays.

EG: I find myself writing a lot of butt ugly code like this to define nested arrays, and it feels like I'm doing something very wrong. I'd be very grateful to anybody who can show me the better way!

$resultsArray = [];
        foreach($relevant_answers as $answer)
        {
            if(! isset($resultsArray[$answer->user_id]))
            {
                $resultsArray[$answer->user_id] = [];
            }

            if(! isset($resultsArray[$answer->user_id][$answer->question_id]))
            {
                $resultsArray[$answer->user_id][$answer->question_id] = [];
            }
            
            $resultsArray[$answer->user_id][$answer->question_id][] = $answer->result;
        }
09 Jul
2 years ago

shawnyv left a reply on Spark Registration Oddity ?

That makes a lot more sense. Thanks!

06 Jul
2 years ago

shawnyv started a new conversation Spark Registration Oddity ?

Hi all,

I'm in the process of writing some integration tests for my new Spark app.

The first one I wrote was to register a new user (I know this is already tested within the Spark framework, but I wanted to have it anyway).

I'm a little concerned with the test feedback I'm getting though - primarily, worried that it's exposing the registration credentials 'over the air' when there's no javascript in place. Here's the test, and the error it's providing:

 public function test_registration_works()
    {
        $name = 'Test Q Testerton';
        $this->dontSeeInDatabase('users',['name'=>$name]);
        $this->visit('/register');
        $this->type($name, 'name');
        $this->type('[email protected]', 'email');
        $this->type('password', 'password');
        $this->type('password', 'password_confirmation');
        $this->check('terms');
        $this->press('Register');
        $this->seePageIs('/home');
        $this->seeInDatabase('users',['name'=>$name]);
    }

And the feedback I'm getting from the failing test is:

 Test  tests/integration/AuthTest.php:test_registration_works
- Expected | + Actual
@@ @@
-'http://localhost/home'
+'http://localhost/register?email=test%40test.com&name=Test%20Q%20Testerton&password=password&password_confirmation=password&terms=on'

Am I wrong to be concerned? Can somebody help shed some light on this for me?

Thanks!

05 Jul
2 years ago

shawnyv left a reply on Vue + Spark Walkthrough Screencast?

Really hoping to see this series soon, it would be wonderful to get a more in depth video guide to working with and modifying the Vue components of Spark (ie the settings screens)

02 Jul
2 years ago

shawnyv left a reply on Moving From Windows To Mac

I made the change about a year ago, after 15+ years on windows only machines as well.

Couldn't be happier - I'd say "Just buy the mac already!"

I originally kept my Windows machine for "business / everything else", and bought the mac strictly for development. That changed within about a month, where I wanted to do everything on the mac.

At this point, I hate getting on my windows machine, but have to for a few things (Excel VBA in the mac is still horrifyingly bad, for the few things I have that still run on macros).

For me it was worth the expense in the time I saved during development - things just work a lot easier (Plus, the other HUGE bonus is that it's just really super easy to follow along the Laracasts lessons, given that you can grab all the tools that you see Jeff using)

shawnyv left a reply on After SSL Install, Can't Access Non-ssl Version

Solved this - I had to go into the nginx config file (handily located in the Forge admin in the "edit files" tiny dropdown just below the Uninstall Repository button), and add the following to the top of it:

server { listen 80 default_server; listen [::]:80 default_server; server_name _; return 301 https://$host$request_uri; }

I screwed up at first by trying to add those 4 lines to the other server {} function, but that just broke both the SSL & non-ssl. Adding that whole chunk got everything working smoothly.

01 Jul
2 years ago

shawnyv started a new conversation After SSL Install, Can't Access Non-ssl Version

Hi all,

I've got a site set up in Forge. I linked my domain name to it. Life was good.

Then I used the Lets Encrypt button in Forge to generate a certificate, and activated the certificate. Now I can log into https://mydomain.com, but when I try to go to http://mydomain.com I get a 404.

Can anybody help me resolve this?

Thanks!

27 Jun
2 years ago

shawnyv started a new conversation Sessions Not Updating In Prod

Hi all,

Not quite sure where to put this.

I was trying to get some simple code to work to add a value to the Session to remember what portion of a drill through my user was at. It worked just fine on my Homestead development, but in my Forge provisioned server, it wouldn't update after the first time it was set. Using Laravel 5.1.

I tried deleting the session (I'm using file based) to no avail, I tried different session names, I tried invoking the session reading & writing boht with Session::put() & $request->session()->put().

Every time it was the same story - worked fine in dev, but on Prod it loaded the first value, then wouldn't load subsequent changes for that session name.

I was trying to use this to set the session:

public function setSessionCity(Request $request, $city = '')
    {
        $request->session()->put('city_session',$city);
    }

And this to look for it within my main route:

$city = '';

        if($request->session()->has('city_session'))
        {
            $city = $request->session()->get('city_session');
        }

I ended up having to abandon using Session and instead created a Cache value that lasts for an hour with the users ID as part of the cache key, but I know that's a very suboptimal option, so any help here would be much appreciated!

25 Jun
2 years ago

shawnyv left a reply on Importing 50k+ Rows To Database From CSV

Hi @nbhagat,

I do it inelegantly (but it works for me) primarily utilizing these two methods:

In this case, $reader is my CSV file, and $headings are the column names that I've retrieved elsewhere

public function add_valid_rows_to_array($reader, $headings)
    {
        $allRows = [];
        $allRowsInterval = 0;
        $rowCounter = 0;

        foreach ($reader as $index => $row)
        {
            $values = [];
            foreach ($headings as $key => $position)
            {
                if (!isset($row[$position]) || is_null($row[$position]))
                {
                    $row[$position] = '';
                }

                $values[0][$key] = $row[$position];
            }
            
            $allRows[$allRowsInterval][] = $values[0];
           
            $rowCounter ++;
            if ($rowCounter > 1000)
            {
                $allRowsInterval ++;
                $rowCounter = 0;
            }
        }

        return $allRows;
    }
public function insert_records_into_location_table($allRows)
    {
        foreach ($allRows as $set)
        {
            Location::insert($set);
        }
    }

I have some additional methods in the add_valid_rows that don't really matter to you, as they're just about checking data-quality, but this is the part that's relevant to setting up my master array and loading those into the database. :)

22 Jun
2 years ago

shawnyv left a reply on Logs For Laravel Testing?

Thanks for the input guys!

Part of me feels better for not missing something obvious in the laravel testing setup, but a much bigger part of me wishes I had!

Codeceptions automatic logging of errors to HTML was a godsend to very quickly see errors for me in my modest suite of 200 acceptance tests.

I guess it's time to learn about phpunit logging / test decorators / etc.