m2sd / nuxt-laravel Goto Github PK
View Code? Open in Web Editor NEWNuxt module for integration with the Laravel framework
License: MIT License
Nuxt module for integration with the Laravel framework
License: MIT License
Hi!
I switched from PHP 7.2 to PHP 7.4 due to some requirements in the laravel context and discovered a strange behavior with the running development servers. After calling yarn run dev
the console starts logging the following entries every 2-3 seconds:
[Sat Mar 14 22:05:55 2020] 127.0.0.1:51100 Accepted
[Sat Mar 14 22:05:55 2020] 127.0.0.1:51100 Closing
[Sat Mar 14 22:05:58 2020] 127.0.0.1:51129 Accepted
[Sat Mar 14 22:05:58 2020] 127.0.0.1:51129 Closing
[Sat Mar 14 22:06:01 2020] 127.0.0.1:51144 Accepted
[Sat Mar 14 22:06:01 2020] 127.0.0.1:51144 Closing
[Sat Mar 14 22:06:04 2020] 127.0.0.1:51159 Accepted
[Sat Mar 14 22:06:04 2020] 127.0.0.1:51159 Closing
[Sat Mar 14 22:06:06 2020] 127.0.0.1:51174 Accepted
[Sat Mar 14 22:06:07 2020] 127.0.0.1:51174 Closing
As you can see, the port changes with every call. Unfortunately i have no idea which process triggers these calls. Do you have any idea or suggestion? If you need more information, just drop me a short line.
Thnx in advance.
Flo
Replace
return file_get_contents(env('NUXT_OUTPUT_PATH', public_path('spa.html'));
With
return file_get_contents(env('NUXT_OUTPUT_PATH', public_path('spa.html')));
In module.js
on line 125, this code is run:
fs_extra_1.default.removeSync(config.output.dest);
But the problem is that by default config.output.dest is set to public/
which can be verified by logging the variable.
I believe that the output should be only removing the nuxt output directory, as laravel has it's index.php
files that are required to be in the public
directory.
I have tried to move the index.php
file to the static/
directory, but it does not copy the files for the development server and the laravel server cannot launch as the `public/' directory no longer exists.
I'm adding Nuxt to an existing Laravel application that has its own HTML layout template and currently expects one JS file. Currently the application uses Laravel Mix to compile everything to one JS file and write the JS assets to the public
folder. Laravel takes care of the rest.
How do I configure nuxt-laravel to do the same thing? It would suffice to deploy the compiled JS files in such a way that I can find them from Laravel and add them to my template. Thanks.
I added nuxt-laravel package in my previous laravel and nuxt based application. By following the "Easy Method" procedure, I could successfully configure the complete application for both laravel and nuxt, build and generate spa into laravel's public directory. My config/nuxt.php
is as follows:
<?php
return [
'routing' => true,
'prefix' => 'app',
'source' => env('NUXT_OUTPUT_PATH', public_path('spa.html')),
'ssr' => env('NUXT_SSR_PROXY', false),
];
I added route('nuxt');
to my routes/web.php
file, which however returns Route [nuxt] not defined.
exception when visiting the url. Is there anything wrong with my configuration? Thanks!
Hi, I'm stuck in rendering my meta tags in server side, crawlers and debuggers (mainly facebook an twitter) do not detect them what is truly sad because this is an amazing package and so glad to use it, but really I can't figure out how to find out a possible solution, so my question is basically what approach do you make to render meta tags and be readable for crawlers/debuggers while has no server rendering? Thanks, any idea will appreciated.
Axios seems to be using wrong default nuxt port 3000.
Can be easly fixed by adding following to nuxt.config.js:
config.axios = {
baseURL: 'http://localhost:3001'
};
Hi, a lot thanks for your effort and time to keep this project shining.
I read in the features that you can access to laravel cookies and session state... is there any helper available for this? or is like "old school" by ajax call and in your controller (IMHO I don't like it)...
return session()->all()
I'm using nuxt-laravel-starter (https://github.com/m2sd/nuxt-laravel-starter)
Thanks in advance.
This plugin is great for an integration more hand in hand with laravel, but with nuxt content something similar to what pwa has happens so I have to think that a similar integration has to be carried out, I hope you can help me integrate it thanks.
I have no idea what I'm doing wrong. The Nuxt server isn't producing the spa.html
file. It's not throwing any error messages either:
$ npm run development
> [email protected] development /home/jay/Documents/industrial
> cross-env NODE_ENV=development nodemon server.js --watch server
[nodemon] 1.19.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching dir(s): server
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node server.js`
Laravel development server started: http://127.0.0.1:3001
[Thu Jun 18 17:11:34 2020] PHP 7.4.7 Development Server (http://127.0.0.1:3001) started
ℹ Preparing project for development
ℹ Initial build may take a while
✔ Builder initialized
✔ Nuxt files generated
✔ Client
Compiled successfully in 17.70s
ℹ Waiting for file changes
Server listening on http://localhost:3000.
Here's my nuxt.config.js
object, stripped down to remove all other dependencies:
{
mode: 'spa',
dev: _isDevelopment,
vue: {
config: {
debug: _isDevelopment,
productionTip: false,
devtools: _isDevelopment,
},
},
laravel: {
dotEnvExport: false
},
head: {
title: process.env.npm_package_name || '',
meta: [{
charset: 'utf-8',
},
{
name: 'viewport',
content: 'width=device-width, initial-scale=1',
},
{
hid: 'description',
name: 'description',
content: process.env.npm_package_description || '',
},
],
link: [{
rel: 'icon',
type: 'image/x-icon',
href: '/favicon.ico',
}],
},
loading: { color: '#fff', },
css: [],
plugins: [ ],
buildModules: [
'@nuxtjs/eslint-module',
],
modules: [
'nuxt-laravel',
],
components: [ ],
build: { extend(config, ctx) {}, },
}
Hi. Whats the point to use nuxt, if i cant use ssr. Maybe someday u realize universal
mode?
WARN nuxt-laravel currently only supports 'spa' mode
Hi.
Referring to the documentation I think there is an error in your code. The documentation said:
If nuxtConfig.router.base is not set the SPA will be generated in the publicDir root with an index file name of spa.html.
If nuxtConfig.router.base is set the SPA will be generated in a corresponding location inside publicDir with the default index file name index.html.
So i was wondering why i got a spa.html in my output folder. After a quick look in your module I think your if-condition has to be changed:
Line 40 in bf42b27
Kind regards,
Flo
Hello.
When using the package on windows (without wsl), I encountered a problem that the links for proxy are not generated correctly.
For example: when used default settings and
// nuxt.config.js
router: {
base: '/app/',
},
NUXT_OUTPUT_PATH equals "http://localhost:3000//app/__nuxt_laravel" which does not work
and proxy rules are incorrect
[
'**/*',
'!\\app\\__nuxt_laravel'
]
This all leads to php server errors, and the inability to open nuxt files.
As a quick fix, you can use the "slash" package.
// https://github.com/m2sd/nuxt-laravel/blob/master/src/module.ts#L136
['**/*', `!${slash(path.join(baseUrl, moduleKey))}`],
// https://github.com/m2sd/nuxt-laravel/blob/master/src/module.ts#L238
slash(path.join(baseUrl, moduleKey)),
On windows, this solves the problem, and everything starts to work correctly.
Or is there some other solution to this problem?
Hi,
So I have a Nuxt.js project and I want to add Laravel.
I added npm install --save-dev @nuxtjs/axios @nuxtjs/proxy nuxt-laravel
And I added 'nuxt-laravel' to modules as well, but I am not sure what the next steps are. When I do npm run dev I get a message that Laravel support is disabled.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.