demo1.mov
- PHP 8.3+
- NodeJS 22+
- Laravel v12
- React (using react-route, recoil, react-i18next and react-i18nify)
- VitejS (bundling js/jsx/ts) with HMR for development
- jest for JS tests
- github actions for php and js tests
- unified translations for react-frontend and laravel
- optional: passwordless login otps via e-mail
- optional: 2fa via laravel fortify
/api: Laravel application/frontend: SPA js application/scripts: script for building js app
Copy api/.env.example to api/.env and change values according to your setup (name, db etc…).
Ensure that you have access to a database and set the credentials in the .env-file.
Then:
$ npm install
$ cd api
$ composer install
$ php artisan key:generate
$ php artisan migrate
$ cd .. # back to project root
$ npm run i18n:setupThen start webserver and frontend server:
$ npm run devChange for your needs:
- routes in
api/routes/web.php,api/routes/api.phpandapi/bootstrap/app.php - e-mail-templates
api/resources/views/emails - change logo(s)
/frontend/assets/logo.svgand/frontend/assets/logo.webp - Set your frontend domain url
FRONTEND_URLin the laravel.env-files
$ php artisan cache:table
$ php artisan queue:table$ npm run dev$ npm run buildIt generates bundled production-ready frontend static files in the /dist-folder.
By default, a translation via deepl is supported. Just set a DEEPL_API_KEY in the top .env-file or a as environment variable. The free deepl api key is sufficient here. All api requests are cached, so only changed values are translated.
Translate with:
$ npm run i18nYou can define custom values to be used for deepl translation in /i18/yaml/$lang.yml. You can also define custom translations in /i18/yaml/custom_translations.yml which will be applied to the end of the process and will be used as final value (helpful if deepl generates inaccurate translations).
Use the i18nify placeholder is frontend Hello, %{name}! and the laravel-placeholder Hello, :name! in the api.
There are two 2fa possible:
- send a OTP via e-mail (the password is not needed in this case)
- use user password and 2fa OTP via authenticator app (recommended)
Please do not enable both at the same time, the login process is not designed for this. If you want to use both, you have to adjust the login process.
To disable OTP 2fa (it's enabled by default) remove TwoFactorAuthenticatable from User-model.
For testing e-mails in development mailpit is recommended, set in your /api/.env-file:
MAIL_MAILER=smtp
MAIL_HOST=localhost
MAIL_PORT=1025TypeScript is not enabled by default, but vite supports it.
To make requests from external domains to the api possible, the following CORS-settings in laravel where added:
api/config/cors.php: added'sanctum/token'topaths
Please check the api api/routes/api.php and web routes api/routes/web.php (used for e-mail landing-pages) to keep only routes you really need.
MIT License
This repo is an opinionated boilerplate for creating projects with a laravel-driven api and a JS SPA as frontend.
Please check carefully all security related settings (CORS, database, mail etc) before deploying on production.
Please ensure that you always run on the latest possible php and js modules 🤓
- REMOVE i18n-react
- api docs
- set expire date of tokens