⚡ Laravel 和 Nuxt.js 套件专为开发而设计,具有最高的 API 性能、预先定义的授权方法、优化的图片上传功能以及用户自定义的模板。
⚡ Laravel 和 Nuxt.js 套件专为开发而设计,具有最高的 API 性能、预先定义的授权方法、优化的图片上传功能以及用户自定义的模板。
The goal of the project is to create a template for development on Laravel and Nuxt with maximum API performance, ready-made authorization methods, image uploading with optimization and ready-made user roles.
$http and useHttp, which extend the capabilities of Nuxt's standard $fetch and useFetch.apps/api + apps/web) with just task runner.Show standalone instructions
cd apps/api && composer install && cd ../web && bun install && cd ../..cp apps/api/.env.example apps/api/.envcd apps/api && php artisan key:generate && php artisan storage:linkphp artisan migrate && php artisan db:seedphp artisan octane:install --server=swoole && php artisan octane:start --host=127.0.0.1 --port=8000cd apps/web && bun run devSingle docker-compose.yml: API runs on Laravel Sail with Octane in watch mode, web runs on oven/bun:1, plus a redis:8-alpine service for cache / queue / session / throttling. Orchestrated via just. just sail ... wraps the upstream vendor/bin/sail for those who want it.
justbrew install just # macOS
apt install just # Debian / Ubuntu
winget install --id Casey.Just --exact # WindowsOther systems: see the full list of packages.
just up -d # start full app (api + web) — :8000 / :3000
just prod -d # production mode (Octane no-watch, web .output/)
just api -d # api only — :8000
just web # web foreground, ephemeral — :3000
just stop # pause containers
just down # remove containersQuick start:
just init # copies .env files, composer install, builds api image, bun install, key:generate, storage:link
just up -d
just a migrate --seedCommon commands:
just # show all recipes
just build # rebuild the api image
just a migrate # `php artisan migrate` in ephemeral container
just sail ... # invoke Laravel Sail directly (e.g. `just sail tinker`)
just composer require ...
just bun add @vueuse/core
just pint # PHP linter
just test # Pest
just down -v # stop and remove volumesTo integrate with the API, enhanced $http and useHttp wrappers are used, expanding the functionality of Nuxt's standard $fetch and useFetch. The $http wrapper includes custom interceptors to replace the originals:
onFetch instead of onRequestonFetchError instead of onRequestErroronFetchResponse instead of onResponseonFetchResponseError instead of onResponseErrorAdditionally, $http predefines a base url, authorization headers, and proxy IP for convenient API work in SSR mode.
For example, the code for authorizing a user by email and password:
In this example, a POST request will be made to the url "/api/v1/login"
useAuthStore() has everything you need to work with authorization.
Data returned by useAuthStore:
logged: Boolean, whether the user is authorizeduser: User object, user stored in pinia storefetchCsrf: Function, fetch csrf tokenfetchUser: Function, fetch user datalogin: Function, login userlogout: Function, remove local data and call API to remove sessionhasRole: Function, checks the roleThe following middleware is supported:
guest: unauthorized usersauth: authorized usersverified: users who have confirmed their emailrole-user: users with the 'user' rolerole-admin: users with the 'admin' roleAll built-in middleware from Laravel + middleware based on roles Spatie Laravel Permissions Middleware
https://github.com/k2so-dev/laravel-nuxt/assets/15279423/9b134491-1444-4323-a7a3-d87833dcdc67
暂无开放 Issues,或尚未同步最近议题。