itstudioat / spa
Initial Laraval Spa Installation
Fund package maintenance!
itstudioat
Requires
- php: ^8.3
- illuminate/contracts: ^10.0||^11.0||^12.0
- laravel/sanctum: ^4.0
- spatie/laravel-package-tools: ^1.16
- spatie/laravel-permission: ^6.17
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.75
- laravel/framework: ^10.0||^11.0||^12.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^10.0.0||^9.0.0||^8.22.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
README
What is Laravel-Spa
Laravel-Spa installs all necessary items for a fresh Laravel Single Page Application.
The installation uses next to laravel:
- Vue with Vue-Router as Javascript-Framework and routing
- Pinia as state store
- Vuetify as css-framework
- Sanctum as authentication-system for single-page-applications
- Vite for asset bundling
It provides:
- Login page together with a 'Unkown password' page and a Register page
- The login use a 2-factor-authentification (password an email), if the user has set 2-fa option
For the authenticated admins it supports
- Dashboard
- Users page, where all users are listed, may be added, changed or deleted
- Profile update with password change
- Logout
It integrates the Spatie roles and you can manage the role-based access to all web- and api-routes.
After installing this package, you can easily start to develop your own single page application with all necessary requirements.
Installation
Install a new laravel project
laravel new new-laravel-app
Make all necessary configurations
-
.env
- APP_URL
- DB-configuration
- MAIL-configuration
- SESSION_DOMAIN='.localhost'
- LOCALE-configuration
-
config/app.php
- timezone
Create an empty database correspondig to the .env configuration
Install this package and run the install-commands
composer require itstudioat/spa
php artisan spa:install php artisan spa:complete
Make important entries in some files
Put this line in composer.json
"autoload": { "psr-4": { ... "Itstudioat\\Spa\\": "app/" } },
Change the config/cors.php file
'supports_credentials' => true,
You may inividualize your logo for mails
php artisan vendor:publish --tag=laravel-mail
Change the file resources/views/mail/html/header.blade.php to:
@props(['url']) <tr> <td class="header"> <a href="{{ $url }}" style="display: inline-block;"> <img src="{{ asset('storage/images/logo.png') }}" class="logo" alt="Your Logo"> </a> </td> </tr>
Install your mailing system
If you use Postmark for mailing (i use it):
composer require symfony/postmark-mailer composer require symfony/http-client
Usage
php artisan serve npm run dev php artisan queue:work
Permissions for routes
Web-Routes
Under routes/meta/web there is for each route.js-file a php-file. Here you may define, which route needs which (spatie-)roles. if the array is empty, no permission is needed.
With a simple command you can synchronize these files. The php-file is made actual with the route-js-file as basis:
php artisan routes:sync
Api-Routes
Api-Routes may secured with the 'api-allowed'-Middleware followed from the allowed roles. In this example all users with the role admin may pass the apis
Route::middleware(['auth:sanctum', 'api-allowed:admin'])->group(function () { ...
Sending E-Mails
That everything works fine, sending E-Mails must be configured. I use Postmark for Mailing and everything is fine. You can find more infos under Laravel/Notifications.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.