Starter monorepo untuk aplikasi multi-platform dengan arsitektur:
backend-web-> Laravel Web + REST API (MySQL)mobile-app-> NativePHP Mobile client (tanpa koneksi DB langsung)desktop-app-> NativePHP Desktop client (tanpa koneksi DB langsung)
Semua akses data dari mobile/desktop wajib melalui API backend:
mobile-app / desktop-app -> HTTPS -> backend-web -> MySQL

- Laravel 12 + Livewire 4 (
livewire/livewire) + Flux (livewire/flux) - Fortify untuk auth berbasis session (web login/register/reset/2FA views)
- Sanctum token auth untuk client mobile/desktop
- Model
Usersudah memakaiHasApiTokens - Endpoint API auth:
POST /api/auth/registerPOST /api/auth/loginGET /api/me(auth:sanctum)POST /api/auth/logout(auth:sanctum)
File penting:
backend-web/routes/api.phpbackend-web/app/Http/Controllers/Api/AuthController.phpbackend-web/app/Models/User.phpbackend-web/app/Providers/FortifyServiceProvider.php
- Laravel 12 + NativePHP Mobile 3 (
nativephp/mobile) - UI Tailwind untuk testing auth:
- Login
- Register
- Me
- Logout
- API client service ke backend (
BackendApi) - Token disimpan terenkripsi lokal (fallback aman) via
Crypt:storage/app/private/auth_token.enc
- Fallback parser request body untuk kompatibilitas WebView form submit
File penting:
mobile-app/routes/web.phpmobile-app/app/Http/Controllers/MobileAuthController.phpmobile-app/app/Services/BackendApi.phpmobile-app/app/Support/AuthTokenStore.phpmobile-app/resources/views/mobile/*
- Laravel 12 + NativePHP Desktop 2 (
nativephp/desktop) - UI Tailwind untuk testing auth:
- Login
- Register
- Me
- Logout
- API client service ke backend (
BackendApi) - Token disimpan terenkripsi via NativePHP Settings +
Crypt - Window bootstrap sudah diset:
- ukuran awal 1280x800
- min size 980x640
- remember state
- DevTools bisa ditoggle via env
NATIVEPHP_OPEN_DEVTOOLS
File penting:
desktop-app/routes/web.phpdesktop-app/app/Http/Controllers/DesktopAuthController.phpdesktop-app/app/Services/BackendApi.phpdesktop-app/app/Support/AuthTokenStore.phpdesktop-app/app/Providers/NativeAppServiceProvider.phpdesktop-app/resources/views/desktop/*
- PHP 8.3+ (direkomendasikan 8.4 di Windows/Herd)
- Composer 2.x
- Node.js + npm
- MySQL server (contoh: Hostinger)
- Untuk mobile: Android SDK/Emulator (NativePHP Mobile)
- Untuk desktop: Electron dependencies (NativePHP Desktop)
git clone <repo-url> laravel-multi-platform-starter
cd laravel-multi-platform-startercd .\backend-web
composer install
npm install
copy .env.example .env
php artisan key:generate
php artisan migrateAtur .env backend:
APP_URL=...DB_HOST=...DB_PORT=...DB_DATABASE=...DB_USERNAME=...DB_PASSWORD=...
cd ..\mobile-app
composer install
npm install
copy .env.example .env
php artisan key:generate
php artisan native:installAtur .env mobile:
API_BASE_URL=http://IP_BACKEND:8000(atau HTTPS domain backend)
Catatan: jangan isi credential DB backend di mobile app.
cd ..\desktop-app
composer install
npm install
copy .env.example .env
php artisan key:generate
php artisan native:installAtur .env desktop:
API_BASE_URL=http://IP_BACKEND:8000(atau HTTPS domain backend)NATIVEPHP_OPEN_DEVTOOLS=false
Catatan: jangan isi credential DB backend di desktop app.
cd .\backend-web
php artisan servecd .\mobile-app
php artisan native:runcd .\desktop-app
php artisan native:runRegister:
curl.exe -X POST http://127.0.0.1:8000/api/auth/register `
-H "Accept: application/json" `
-H "Content-Type: application/json" `
-d "{\"name\":\"Test\",\"email\":\"test@example.com\",\"password\":\"password123\",\"password_confirmation\":\"password123\",\"device_name\":\"postman\"}"Login:
curl.exe -X POST http://127.0.0.1:8000/api/auth/login `
-H "Accept: application/json" `
-H "Content-Type: application/json" `
-d "{\"email\":\"test@example.com\",\"password\":\"password123\",\"device_name\":\"postman\"}"Me (gunakan token dari login):
curl.exe http://127.0.0.1:8000/api/me `
-H "Accept: application/json" `
-H "Authorization: Bearer TOKEN_ANDA"- Mobile/Desktop tidak boleh connect langsung ke MySQL.
- Semua CRUD lewat
backend-webAPI. - Auth web (session/Fortify) dan auth API (Sanctum token) dipisah dan bisa berjalan bersamaan.