Php Laravel Mac Linux Issues
We’re looking to enter into a partnership with a talented guy to improve some of our design on Pockets and we needed to get the site running in a dev version on his system.
We were surprised when we started seeing some errors on his side around our Blade components.
Specifically we had a constructor function which was empty for a blade component being called with code like this:
<x-filters.product-view
:model=$retailer
:products="$products"
:searchvalues="$searchvalues ?? ''"
:sortByOptions="$sort_by_options ?? ''"
/>
This error was that the constructor should have had a parameter for each of these, which is actually a reference to how they need to exist in the class as member variables, but since PHP8.0 you can do that in the constructor function.
But why was this an issue on Mac, and not on our machines?
Short answer, because it was a Mac, and Mac’s have a kind of case insensitive lookup while holding a preferred case for display purposes. We had created a blade component years ago, and for somereason, the associated class wasn’t in the expected case. Linux couldn’t find it, and Mac could.
Laravel does a bunch of magic on parameters which relies on knowing when to use camelCase, snake_case, or whatever.
There’s a good Reference to the Laravel Conventions here
Get it wrong and things go wrong in strange ways. It’s probably the number one valid argument against Laravel.