gammamatrix/site-api-angular

Playground: This is a base application site for Laravel based Playground APIs and Angular UIs.

dev-develop 2024-07-25 18:17 UTC

This package is auto-updated.

Last update: 2025-02-25 19:32:39 UTC


README

Playground CI Workflow Test Coverage PHPStan Level 9 src and tests

Site: Playground API and Angular SPA Integration Package for Laravel v11 and Angular v16, v17, v18 applications.

Read more on using Site: Playground API and Angular SPA Integration at Read the Docs: Playground Documentation.

Angular Application

Site: Playground CMS UI with Angular

Currently, there are two Angular applications available to use with this base Laravel application.

CMS with Angular v16 and Angular Material

See: gammamatrix/site-playground-cms-angular

Screenshot of the CMS Dashboard with Angular v16 and Angular Material

Screenshot of the CMS Snippets Index with Angular v16 and Angular Material

CMS with Angular v18 and Bootstrap v5

See: gammamatrix/site-playground-cms-angular-bootstrap

Screenshot of the CMS Dashboard with Angular v18 and Boostrap with dark mode

Toggle User Information

Users

By default, this application uses a user with a UUID for a primary key: app/Models/PlaygroundUser.php.

  • auto-incrementing is also supported with the standard app/Models/User.phps, which has been renamed as a source file.
Toggle Testing and Development Information

Testing and Development

Users

Playground Test provides a custom user table seeder: CustomUsersTableSeeder for development.

The user model is set up in config/auth.php:

'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => env('AUTH_MODEL', App\Models\PlaygroundUser::class),
    ],
],

Setting up users for testing

For security reasons, the CustomUsersTableSeeder must be manually linked or copied to this application:

cd database/seeders
ln -snf ../../vendor/gammamatrix/playground-test/resources/CustomUsersTableSeeder.php
Toggle Dev Notes

Dev Notes

A base Laravel installation was used.

composer create-project laravel/laravel site-api-angular

Enabled Sanctum

Added Laravel\Sanctum\HasApiTokens to the User model.

php artisan install:api
php artisan config:publish cors
SESSION_DOMAIN=site-api-angular
# SESSION_DOMAIN=site-playground-integration
SESSION_HTTP_ONLY=false
SESSION_SECURE_COOKIE=false

SANCTUM_STATEFUL_DOMAINS=site-api-angular
composer require gammamatrix/playground-cms-api
  • composer.json need to allow "minimum-stability": "dev",

nginx configuration for the PHP API and Angular app

resources/configuration/31010-site-api-angular.conf

  • Note development is done on http with scheme-less URLs, where possible.