Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Laravel to Nuxt #6

Open
bitfactory-sarah-tammenga opened this issue Apr 20, 2020 · 2 comments
Open

Add Laravel to Nuxt #6

bitfactory-sarah-tammenga opened this issue Apr 20, 2020 · 2 comments

Comments

@bitfactory-sarah-tammenga
Copy link

bitfactory-sarah-tammenga commented Apr 20, 2020

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.

@mentAl-maZe
Copy link
Member

Hi @bitfactory-sarah-tammenga,

Let's clarify some things in advance:

PHP is a server side scripting language and, in production, will need to be set up properly through a web server and a process manager (e.g. nginx + php-fpm)
Consequently this module does not provide any means to serve a production ready PHP server. Please plan accordingly


The module disables Laravel support if it is unable to find the artisan PHP executable, which is located at the root of a Laravel project folder.
If you do not already have one please follow the following steps to create one (see https://laravel.com/docs/7.x/installation#installing-laravel):

  1. setup PHP and composer on your system (depending on which operating system you use this step may vary)
    Here are some resources to get you started:
  2. Globally install the laravel installer: composer require global laravel/installer
  3. Create a new laravel project: laravel new projectName
    Note: this will create a folder named projectName, containing a full laravel installation, under the current working directory (i.e. the folder form which the command was executed)

Once you have a laravel project setup you can direct this module to it's directory as follows:

In nuxt.config.js:

export default {
  // ...
  modules: [
    'nuxt-laravel'
    // ...
  ],
  // ...
  laravel: {
    // A relative path will be resolved relative to the current working directory (i.e. the directory you execute 'yarn dev' from
    root: 'relative/path/to/laravel/project/directory'
    // An absolute path (note the leading '/') will be used as is
   root: '/absolute/path/to/laravel/project/directory'
  }
}

After the root is set the module should work correctly.

@mentAl-maZe
Copy link
Member

Also:
Laravel will not support this module natively, in order for Laravel to proxy calls to NuxtJS's internal router you need to configure a route (see: https://github.com/m2sd/nuxt-laravel#forwarding-all-undefined-routes-to-nuxt and mind the router.base setting in your nuxt.config.js, as this must be the prefix for any route which proxies to nuxt)

Alternatively (if you want to start fresh):
You can use the m2s/larave-nuxt plugin as descibed here: https://github.com/m2sd/nuxt-laravel#the-easy-way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants