Laravel API and Vue SPA or inline Vue? - laravel

When working with Laravel, it seems I can use Vue inside the Laravel Blade but I can also use Laravel project only as an API while using another project (Vue in this case) as a front-end connecting to the API?
Which approach is better and has its advantages/disadvantages?

Related

How can I use laravel localization into vue components?

I'm currently working on application's translation with Laravel Localization (laravel 5.6).
I succeed my text translation on blade templates but I have some view using vuejs.
Into them I can't use directly laravel localization.
I understand that I have to send my translations files (which are in PHP) into the vue in JS.
I found some packages like :
https://github.com/rmariuzzo/Laravel-JS-Localization ; but it doesn't support laravel 5.6 (damned)...
https://github.com/martinlindhe/laravel-vue-i18n-generator ; Laravel 5 package is no longer maintain...
This application use Laravel 5.6 and vue 2.
I can't completely reorganize or upgrade Laravel or vue version.
After many research I'm still not able to do it...
Do you know how can I made translation into my vue component?
Thanks a a lot!

Few questions when it comes to building an e-commerce website in Laravel and vue

I have a few questions regarding building an e-commerce website. I want to program a small e-commerce website using Laravel and Vue. I know the basics of Laravel and Vue, but I'm struggling when it comes to selecting the best plan to program the website. So I have a few questions regarding that.
Should an e-commerce website be dynamic or SPA?
Should I use a Vue router or built-in Laravel router?
Is it good practice to mix Vue components and Blade Template or should I separate Vue and Laravel when it comes to the frontend?
Suggest you use nuxt universal, cuz need seo, spa didnt index well in search engine
For client side use Vue router, for rest api use laravel router
If you use vue + nuxt dont need blade

How to include complex Vue app inside Laravel

I have a Laravel project, which should contain different Vue apps.
Some of these apps are quite-complex (stand-alone app.js file with its own components).
How can Laravel manage different vue apps, each one with its own app.js file and components?
One approach to solve this problem is to write vue apps as SEPARATE projects (using only frontend technologies) which connect with laravel using RESTful API.
This is in fact simple micro-services architecture (which include the hard separation between frontend and backend code). If you decide to do it, you will face CORS problem (but don't worry - you will find many solutions on internet e.g. this) because the vue app will be on different domain/subdomain that your RESTful laravel API.
Laravel support create restful API controllers - cmd:
php artisan make:controller API/MovieController --api --model=Movie
routing routes/api.php:
Route::group(['prefix'=>'v1'], function() {
Route::apiResource('movies', 'API\MovieController');
...
});
It is good to use for api authentication Laravel Passport (oauth2)
You should also build your separate vue applications using some modern frontend technologies like webpack, nmp (here is some example but you will probably find better)... long story - but this is good direction :)

Integrate Vue.js with laravel

I have built my static design using vue.js. Now, I need to integrate it within Laravel.
Once I do integrate Laravel with Vue then Laravel is not getting the Design files path. I mean the various Style and JS files.
FYI, I build the Vue in static design and it was working fine before integration with Laravel. But, while integrating with Laravel I am no longer using the build or build.js file. Instead of this, I am building using Laravel ways.
The main issue is the design is broken and the route is not working.

how to uses ReactJS and Laravel

how to combine Laravel and React? I mean, Laravel uses blade for its view, how to change it to React instead of blade ? There have been so many Laravel and Angular tutorial, but I can't find any for React and Laravel?
Any references of Laravel and ReactJS tutorial ?
If you are using Laravel to build a REST web service (API), then you might not need Blade. You just return JSON data. Your React App can then make calls to the Laravel API for data and process it right in the browser. You don't need Blade for this.
You would use Laravel to provide the base view (index.blade.php) which would include the React JS app, but then after that all the views and routing would be handled by React.
Here's a link to get you started.
https://medium.com/#rajikaimal/laravel-loves-reactjs-8c02f8b9d1d5
I have created laravel reactjs starter project .. refer the github project below.
I am not using the mix api of laravel since I want reactjs app to be portable to any other server or standalone app
refer the link below
https://medium.com/#padmanabhavn/bringing-laravel-and-reactjs-together-8c970cb0f65d
This question seems old but I will still share my experience for others.
This tutorial and project sample may be found useful.
https://blog.pusher.com/react-laravel-application/
https://github.com/maarcz/taskman
As well as that, the solution below has worked for me in webpack.mix.js without using app.js to be mixed up with other requirements (laravel 8):
mix.js('resources/assets/js/react', 'public/js/reactJs').react()
in blade:
<script src="{{ asset('js/reactJs/react.js') }}"></script>

Resources