m2s / laravel-nuxt
Laravel 集成 NuxtJS 框架
1.2.0
2020-09-13 09:04 UTC
Requires
- illuminate/support: ^8.0
- laravel/framework: ^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- pedrotroller/php-cs-custom-fixer: ^2.23
- phpmd/phpmd: ^2.8
- phpro/grumphp: ^0.18.0
- squizlabs/php_codesniffer: ^3.5
- dev-master
- 1.2.0
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.2
- 1.0.1
- 1.0.0
- dev-dependabot/npm_and_yarn/decode-uri-component-0.2.2
- dev-dependabot/npm_and_yarn/path-parse-1.0.7
- dev-dependabot/composer/league/flysystem-1.1.4
- dev-dependabot/npm_and_yarn/hosted-git-info-2.8.9
- dev-dependabot/npm_and_yarn/handlebars-4.7.7
- dev-dependabot/composer/laravel/framework-8.40.0
- dev-dependabot/npm_and_yarn/y18n-4.0.1
- dev-dependabot/npm_and_yarn/ini-1.3.8
- dev-feat/nuxt-ssr
This package is auto-updated.
Last update: 2024-09-05 20:35:59 UTC
README
此包便于将使用 NuxtJS 构建的 SPA 集成到现有的 Laravel 项目中。
安装
composer require m2s/laravel-nuxt
安装后,您可以发布配置。
php artisan vendor:publish --provider="M2S\LaravelNuxt\LaravelNuxtServiceProvider"
设置
该包提供了一条命令,用于方便地安装和集成 Nuxt 项目。
$ php artisan nuxt:install -h Description: Create a new nuxt project or setup integration of an existing one Usage: nuxt:install [options] [--] [<source>] Arguments: source Root folder of the nuxt application [default: "resources/nuxt"] Options: -y, --yarn Use yarn package manager -t, --typescript Use typescript runtime -c, --cache[=CACHE] Optional caching endpoint (e.g. /api/cache) -p, --prefix[=PREFIX] Prefix for the nuxt application (will use value from `config('nuxt.prefix')` if omitted) --no-export Do not export env variable on build -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question --env[=ENV] The environment the command should run under -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
自动路由
默认情况下,该包会自动添加 Nuxt 页面的路由。
Nuxt::route('/{path?}')>where('path', '.*')>name('nuxt');
此路由名为 'nuxt'
,可以使用 Laravel 的路由助手使用。
route('nuxt'); // or route('nuxt', ['path' => 'some/deep/path']);
您可以通过在 config/nuxt.php
中的 'routing'
设置中禁用/启用自动路由。
手动路由
该包提供了一个简单的外观,可能用于注册 Nuxt 路由。
路由将自动使用配置的路径前缀,并附加一个控制器来处理内部重定向到 Nuxt。
此方法返回一个 Illuminate\Routing\Route
实例,并可像正常一样使用。
在 routes/web.php
use M2S\LaravelNuxt\Facades\Nuxt; Nuxt::route('example/route')->name('nuxt.example');