are you running composer install as part of your deployment?
Livewire configuration issue in production environment
I have started creating a Laravel app with Livewire.
To make sure the app will work in the production environment I have done a test deploy in a very early stage of the app. Unfortunately the profile edit part of the app is not working (but working in the development environment). The content (the user info) is not displayed on the page. When I look at the html source code the information seem to be present in the code though (in the <div wire:id="foo" wire:initial-data="...">-section), just not displayed.
I am using deploy.php for deployment to the production (shared) environment. It is basically the default setup but with the following modifications:
- I have overridden the deploy:writeable task (not needed as I figure the files needed to be writeable are so already which I have checked).
- I have added a
deploy:uploadEnvtask to upload .env file (to avoid having credentials on GitHub). - I have added a
deploy:setAccesstask to tailor the rights to my production environment. - I have added a
deploy:shorcutLinkto make a shortcut to the app (avoiding having to use the full webapp/public URL).
Installation and running composer is part of the deployment. I have checked that the installed packages are the same on production as when deployed to my development environment. I have also done a raw copy without running composer installation.
My .gitignore looks like this:
/node_modules
# /public/build
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env-prod
.env.backup
.env.example
.phpunit.result.cache
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
/.idea
/.vscode
I have tried using deploy both through GitHub-repo and directly using deployer rsync add on with the same result. I have tried a raw copy from my development environment. I have done deployment to my development environment and the web app works fine there. I have cleared up the prod environment config with:
php artisan cache:clear
php artisan config:clear
php artisan optimize:clear
My developer environment is running MacOS and the production is running Ubuntu.
What I notice when I compare the html source code of the problem page in the development and production environment is the following:
- Seemingly trivial missing comments in production:
<!-- Livewire Styles -->and<!-- Livewire Scripts --> - In the development environment there are checks for loaded Livewire and Alpine which I don't find in production.
- The check for Alpine loaded in development is replace with this in prodction:
window.deferLoadingAlpine = function (callback) {
window.addEventListener('livewire:load', function () {callback();});
};
let started = false;
window.addEventListener('alpine:initializing', function () {
if (! started) {
window.livewire.start();started = true;}
});
document.addEventListener("DOMContentLoaded", function () {
if (! started) {window.livewire.start();started = true;}
});
Why doesn't my web app work in production and how come I have these differences?
This livewire.php configuration workes:
...
'asset_url' => '/fooapp/current/public',
...
'app_url' => 'https://bar.com/loppeadm/current',
Here you replace fooapp with the folder name of your non-root app and bar.com with your domain name.
Please or to participate in this conversation.