I already deployed successfully a Laravel and vuejs project to AWS.
I put the project and app.js everything, into ~/laravel then i created a symlink in /var/www/html/laravel/ that point to ~/laravel/public
It is working fine.
I got one problem, whenever i pull a new code including app.js from the branch in github. The code is updated, but when i go to the website, its not updating yet. Several hours later, its back to normal with my new updated code.
Its driving me nut cause i can not test it right away
any suggestion
Thank you
I encountered this behavior when the server was enabled OPcache.
try clear OPcache
https://jenssegers.com/77/clearing-php-s-opcache-with-cachetool
Adding a version number on your app.js every time you compile your assets should fix this. If you are using Laravel mix, simply add on webpack.mix.js file
if (mix.inProduction()) {
mix.version(); // this will add a version number to your app.js
// every time you do `npm run production`
// ex: app.js?id=b35f8fd52c344cb84a52
}
Related
I have been running into this very weird issue with Laravel.
I had a problem where one of my component views was not able to read the variables defined in its class. It was kind of strange because I have several components running in my project and they all worked fine, except for this one.
So I created a fresh Laravel project to test some things out (Wanted to check if the problem was on my end, maybe I somehow messed up the project files).
I created a new component on a blank project using php artisan make:component top_nav
pre function basically is used as print_r which is in helper.php
Then I simply added a sql_data variable to the class component like so:
i tried many thing as much as i can do but still i can't access that variable
also clear cache of view
of laravel
change name of components but still can't work
kindly help me..........
you should
return view('components.top_nav', ['sql_data' => $sql_data]);
you are not passing the variable to the view
composer install
npm install && npm run dev
php artisan optimize
I just copied your screenshots into a new laravel installation and ran it with no problems.
Try setting the public property with a default value:
public $sql_data = 'testing'
If you try the above and still have issues, I'd like to confirm the output of AdminLogin::all().
PS:
TopNav instead of top_nav Class name please.
So I tried creating a new project using Breeze+vue in Laravel.
I was following this guide: https://www.youtube.com/watch?v=A7UlfXPhsaA
When I finally got vite running on npm run dev without issues, I came across the app_url and I tried to change it to something similar like in that guide (timestamp 6:14 in video), in my case the app_url value was just http://localhost and I changed it to http://grandia.test.
And it reflects like that when vite is running:
VITE v3.1.0 ready in 1031 ms
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
LARAVEL v9.28.0 plugin v0.6.0
➜ APP_URL: http://grandia.test
but nothing happens when I go to the site. only the localhost:5173 works properly.
I tried googling for answers but I couldn't find anything helpful.
Could someone help me out what I'm doing wrong or missing? Thanks!
I had the same issue, It look like you changed URL: http://grandia.test instead of localhost. So you should try with npm run build instead.
Changing Laravel’s APP_URL parameter will not magically allow you to choose the URL your website is served at. It will only tell Laravel what it should use when generating URLs related to your website.
The video’s author uses the Laravel Valet local development environment. It provides a park command that allows you to automatically serve the subfolders of some folder (e.g. Sites in the video) at http://<subfolder>.test.
In the video, the project is created in Sites/reddit-clone/, which makes it possible to directly access it at reddit-clone.test.
I'm building a web app using Laravel 8.6, Vue 3.2, and hosting on AWS with Laravel Forge. Everything works fine locally and on staging. However, when I deploy the app to production, some people initially see a blank white screen. They don't see any errors in the console. This problem is fixed with a hard refresh on the browser. However, when I try to replicate this issue locally, I can't replicate it.
The only real difference between local and staging and production is that on production, I'm running "npm run prod", which runs "npx mix --production".
Could this be an error in the server configuration? Any idea how to solve?
I appreciate any comments or suggestions!
Could be related to the users in production having a cached copy of your assets, if not already, can you add to your webpack.mix.js file:
if (mix.inProduction()) {
mix.version();
}
To ensure that users are getting a fresh copy of your assets when you deploy to production (https://laravel.com/docs/9.x/mix#versioning-and-cache-busting )
I finally found the answer.
The problem was that Laravel Mix was adding a hash to app.js, but NOT adding it to the chunked bundles.
I needed to change up the webpack.mix.js file and add the chunkhash to the output. This ensured that the chunked files weren't brought in from disk cache.
For example:
mix.webpackConfig({
...
output: {
chunkFilename: '[name].js?[chunkhash]',
}
})
Note that I added the ?[chunkhash] after the filename.
Here was my inspiration: https://laracasts.com/discuss/channels/vue/laravel-vue-files-requiring-hard-refresh-even-when-caching-implemented
I'm deploying a Laravel app to Vapor and cache is automatically deleted right after the deploy. I also clear it manually via CLI just to be sure. Still, it's not running with the updated build because it can't find a Class that instead it's there (double checked the namespaces and everything else). On my local machine it's working fine, the class is found and so I can instantiate it.
I tried to clear every possible cache (route, config, view, also run a composer dump-autoload) but nothing seems to work. Any clue?
I'm using Laravel Nova v1.1.4 within docker container.
I created a new tool via nova:tool command. Everything seems to be ok but everytime I update my vue component (tool.vue) the application does not display the updated data.
I run "npm run dev" from within /nova-components/myComponent/ directory, compiling is working fine but the application does not get updated.
My webpack.mix.js is the following:
let mix = require('laravel-mix')
mix.setPublicPath('dist')
.js('resources/js/tool.js', 'js')
.sass('resources/sass/tool.scss', 'css')
I think is a "refresh" problem, in fact after "npm run dev" execution if I stop and restart the docker containres and refresh the web page then it displays the updated information I included in the vue componenet of the custom tool.
Do yuo have any idea to avoid containers stop/start?
Any help will be great.
Thanks,
MaxdB71
You need to either disabled your cache in Chrome(or your browser of choice):
Or you need to implement versioning:
https://laravel.com/docs/5.7/mix#versioning-and-cache-busting
If you have not done implemented one of these solutions you will simply get served the same file over and over until your cache expires.