Troubleshooting
Middleware order
Don't forget to set \App\Http\Kernel::$middlewarePriority when adding new middleware, so all resources are loaded in the correct context.
502 Bad Gateway error
Delete the storage/clockwork/clockwork.sqlite file.
Trying to get property 'name' of non-object (stores)
The $store variable is explicitly passed to the Markdown email, but is null when the notification is sent through e.g. Horizon.
The StoreViewComposer sets the $store variable for all store views using a wildcard. Of course this includes emails. While the $store variable is set when sending notifications synchronously without queue because the request originates from within the store admin, it's null when dispatched in a clean queue environment.
Fix
Do not bind the store variable to a view if there is no store.
Users get a 403 forbidden when accessing a questionnaire
Make sure to update the questionnaire openings for all participants (using a migration) when changing questionnaire IDs. Otherwise their pending questionnaire openings data will be out of sync.
dispatch(new UpdateParticipantQuestionnaireOpenings($event->participant));BladeX throws errors when used with view models
When using BladeX in combination with view models, all variables are determined and defined before the view is rendered, so make sure no variable depends on another (i.e. conditional checks using view model variables).
Sizing Phosphor icons with Tailwind CSS doesn't work
If you're styling child Phosphor icons with regular CSS, you need to set the size attribute on the icon so it picks up the non-direct styling.
<div class="parentstyle">
<PhMagnifyingGlass weight="regular" size="auto" />
</div>.parentstyle svg {
@apply w-4
}Exit Code: 127 (Command not found)
This error can be thrown if you're executing commands from PHP that's called via nginx and PHP-FPM, but the required binary is not in any of the default directories:
/usr/gnu/bin
/usr/local/bin
/bin
/usr/bin
.The reason for this is PHP-FPM clears and resets all ENV variables, so none are inherited from your default user's setup.
The (simplest) solution is to symlink the required binaries from any of the default directories:
ln -nfs /opt/homebrew/bin/mysql /usr/local/bin/Or for a specific version:
ln -nfs /opt/homebrew/opt/mysql@8.0/bin/mysql /usr/local/bin/Or manually set the PATH environment variable inside your PHP code:
putenv('PATH=/opt/homebrew/bin')Or update PHP-FPM's www.conf file to inherit the default PATH (/opt/homebrew/etc/php/8.X/php-fpm.d/www.conf for Valet on macOS):
env[PATH] = $PATH
# Or
env[PATH] = /opt/homebrew/binAlso see:
- https://janostlund.com/2020-08-14/symfony-process-127-error
- https://stackoverflow.com/questions/19659675/no-environment-variables-are-available-via-php-fpmnginx
- https://medium.com/@tomahock/passing-system-environment-variables-to-php-fpm-when-using-nginx-a70045370fad
- https://serverfault.com/questions/915920/getting-environment-variables-in-php-fpm-with-nginx
Log full exception messages and function parameters
In case your logged exceptions arguments are getting truncated like
Str::replaceArray('?', Array, 'insert into `or...')Set this in your php.ini and restart php-fpm (if you're using Laravel Herd, from the menu bar "show php.ini" + start and stop). This removes the truncation limit on function arguments in exception traces. By default it truncates function parameters at 15 bytes.
zend.exception_string_param_max_len=1000000Note that 0 might work too. See https://www.php.net/manual/en/ini.core.php#ini.zend.exception-string-param-max-len.
Now when you check your logs, you get actually usable data:
Str::replaceArray('?', Array, 'insert into `table` (`type`, `name`, `description`, `article_number`, `price`, `vat_percentage`,`enabled_at`, `state`, `updated_at`, `created_at`) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)')See https://stackoverflow.com/a/77347612/2362944 for the discussion.
Deprecations
ctype_digit()
ctype_digit(): Argument of type null will be interpreted as string in the future in vendor/propaganistas/laravel-fakeid/src/RoutesWithFakeIds.php on line 18This deprecation concerns the combination of 3 packages:
barryvdh/laravel-ide-helperstaudenmeir/eloquent-has-many-deeppropaganistas/laravel-fakeid
It happens because the ide-helper:models --write-mixin --reset command triggers eloquent-has-many-deep's DeepRelationsHook, which in turn tries to invoke all public methods of a model to check if they're a deep relation class. In our custom BaseModel, we have a getPublicIdAttribute() method that gets called and in turn calls laravel-fakeid's getRouteKey() trait method. Because the model's key is null when used in a CLI environment, it's passed to ctype_digit($key) and resolves to ctype_digit(null), causing the deprecation warning 🙃
mb_strwidth()
mb_strwidth(): Passing null to parameter #1 ($string) of type string is deprecated in vendor/laravel/framework/src/Illuminate/Support/Str.php on line 596The cause of this deprecation warning is probably the same as ctype_digit()'s, but related to the Provider's getExcerptAttribute() and other methods that use Str::limit() with a null value (as the model hasn't been initialized and is used without values).
Github actions don't cache
The actions/cache action isolates caches between branches, so each first run of it in a new branch will start from scratch.
Deleting GitHub actions' cache
Run locally:
gh cache delete --allDeploy process timeouts
[smarthealth-app-local-worker-1] run ps x | grep 0654ffdedac0da1120a3 | grep -v grep | awk '{print $1}'
[smarthealth-app-local-worker-1] run kill -9 -
[smarthealth-app-local-worker-1] bash: line 1: kill: -: arguments must be process or job IDsIf you get a vague error like this when using Deployer, it's a combination of a low timeout (set('default_timeout', 60);) and a bug in Deployer that doesn't properly handle an empty process ID (PID).
The solution is to increase the timeout, either globally or per run() call.