From the way you describe it, I don't think the problem lies in your code. Sounds to me like there is some sort of caching going on on your production server, maybe.
Laravel running old code
Hey guys,
I've got my application running on a Forge managed server, which deploys my code when changes have been made to the master branche.
For testing purposes, I added a Logging statement to my MessageSending event, which is fired when a mail is being send. It works great on my Laravel Homestead environment, but doesn't always get triggered on my production environment. The logging statement was meant for debugging, to check whether the code was being executed at all.
Once I figured out that it was sometimes running and sometimes not, I deleted the line which logged 'Jeej, you're being handled!'. However, around 20 deployments later, that line is still being logged.. My production environment is thus running old code.
I've tried many things which I read on the internet. For example php artisan clear-compiled, or composer dumpautoload. These made no difference however.
Does anybody know what the issue is?
My deployment script:
cd /home/forge/geekk.nl
git pull origin master
composer dumpautoload
composer install --no-interaction --no-dev --prefer-dist
echo "" | sudo -S service php7.1-fpm reload
if [ -f artisan ]
then
php artisan cache:clear
php artisan deployments:migrate
fi
php artisan horizon:terminate
And composer.json file:
...
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postInstall",
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\\Foundation\\ComposerScripts::postUpdate",
"php artisan ide-helper:generate",
"php artisan ide-helper:meta",
"php artisan clear-compiled",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
}
That's my initial thought too. I tried one solution which I hadn't done before, running php artisan optimize --force and suddenly, my problems where gone.
It's really strange that without the --force flag, it doesn't work on deployment, but with the flag, it does.
Please or to participate in this conversation.