├── .editorconfig ├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── composer.json ├── config └── nuxt.php ├── phpcs.xml └── src ├── Controllers └── NuxtController.php └── LaravelNuxtServiceProvider.php /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | 15 | [*.{php,json}] 16 | indent_size = 4 17 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | /composer.lock 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Cristian Pallarés 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Warning: this project has been deprecated 2 | 3 | `laravel-nuxt` was created to offer some sugar when working locally with Laravel+Nuxt, solving some cookie problems in the process. Today, it isn't necessary anymore. 4 | 5 | We recommend using [Laravel Sanctum](https://laravel.com/docs/8.x/sanctum), which plays nicely with SPAs (see [Sanctum's SPA Authentication section](https://laravel.com/docs/8.x/sanctum#spa-authentication)). If you can't migrate, just keep using `laravel-nuxt`. 6 | 7 | # Laravel Nuxt 8 | 9 | This package allows you to build a SPA with Laravel and Nuxt. 10 | 11 | ## Installation 12 | 13 | ```bash 14 | composer require pallares/laravel-nuxt 15 | ``` 16 | 17 | In Laravel 5.5 the service provider will automatically get registered. In older versions of the framework just add the service provider in `config/app.php` file: 18 | 19 | ```php 20 | return [ 21 | // ... 22 | 'providers' => [ 23 | // ... 24 | Pallares\LaravelNuxt\LaravelNuxtServiceProvider::class, 25 | ], 26 | ]; 27 | ``` 28 | 29 | You need to add a fallback route that will render the SPA page in `routes/web.php` file: 30 | 31 | ```php 32 | // ... 33 | // Add this route the last, so it doesn't interfere with your other routes. 34 | Route::get( 35 | '{uri}', 36 | '\\'.Pallares\LaravelNuxt\Controllers\NuxtController::class 37 | )->where('uri', '.*'); 38 | ``` 39 | 40 | Finally, you must install the [laravel-nuxt](https://github.com/skyrpex/laravel-nuxt-js) npm package. After following the instructions, run `npm run build` and try your SPA! 41 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pallares/laravel-nuxt", 3 | "description": "Build a SPA with Laravel and Nuxt", 4 | "keywords": [ 5 | "laravel", 6 | "nuxt", 7 | "vue", 8 | "spa" 9 | ], 10 | "homepage": "https://github.com/skyrpex/laravel-nuxt", 11 | "license": "MIT", 12 | "authors": [ 13 | { 14 | "name": "Cristian Pallarés", 15 | "email": "cristian@pallares.io", 16 | "homepage": "https://pallares.io", 17 | "role": "Developer" 18 | } 19 | ], 20 | "require": { 21 | "php": ">=7.0.0", 22 | "laravel/framework": "5.5.*|5.6.*|5.7.*|5.8.*|^6.0|^7.0|^8.0" 23 | }, 24 | "autoload": { 25 | "psr-4": { 26 | "Pallares\\LaravelNuxt\\": "src/" 27 | } 28 | }, 29 | "extra": { 30 | "laravel": { 31 | "providers": [ 32 | "Pallares\\LaravelNuxt\\LaravelNuxtServiceProvider" 33 | ] 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /config/nuxt.php: -------------------------------------------------------------------------------- 1 | env('NUXT_URL', public_path('_nuxt/index.html')), 12 | 13 | ]; 14 | -------------------------------------------------------------------------------- /phpcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/Controllers/NuxtController.php: -------------------------------------------------------------------------------- 1 | expectsJson()) { 14 | abort(404); 15 | } 16 | 17 | // In production, this will display the precompiled nuxt page. 18 | // In development, this will fetch and display the page from the nuxt's dev server. 19 | return file_get_contents(config('nuxt.page')); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/LaravelNuxtServiceProvider.php: -------------------------------------------------------------------------------- 1 | mergeConfigFrom(__DIR__.'/../config/nuxt.php', 'nuxt'); 17 | } 18 | } 19 | --------------------------------------------------------------------------------