/laniakea-demo

Demo application that uses `laniakea/laniakea` package.

Primary LanguagePHPMIT LicenseMIT

Laniakea Demo

This is demo Laravel 11 application that uses laniakea/laniakea package.

Learn more about Laniakea.

Requirements

This application requries PHP 8.2+ and Node 18+. It also uses sqlite database with demo content.

Installation

# Clone the repository
git clone https://github.com/tzurbaev/laniakea-demo.git

# Install dependencies
cd laniakea-demo
composer install
npm install

# Build assets
npm run build # or start development server with `npm run dev`

# Copy .env.example to .env
cp .env.example .env

# Create empty sqlite database
touch database/database.sqlite

# Run migrations
php artisan migrate

# Run seeders
php artisan db:seed

# Start built-in server
php artisan serve # or create Valet link with `valet link`

What's inside

This is a books database application where you can create authors, genres, and books.

It uses all Laniakea features, including resources, repositories, API versions, model settings, and forms.

API

This application has a simple API that allows you to paginate, create, and show app resources (authors, books, and genres). Books API also supports editing.

All API routes are described inside routes/api.php file. It contains two API versions (v1 and v2) that are available at http://localhost:8000/api/v1 and http://localhost:8000/api/v2 respectively.

Filters

Authors, Genres, and Books resources all support several filters. Check respective classes (inside app/Resources directory) to see available filters.

Directory structure

All application code is located inside app directory. It contains the following subdirectories:

  • Actions – contains actions that are used in controllers (create or update models);
  • Enums – contains enums that are used in application;
  • Exceptions – contains custom exceptions;
  • Forms – contains form classes that are used on frontend;
  • Http – contains controllers and requests;
  • Interfaces – contains interfaces that are used for API versioning;
  • Models – contains Eloquent models;
  • Repositories – contains Laniakea repositories and criteria;
  • Resources – contains Laniakea resources, filters, and resource registrars;
  • Settings – contains Laniakea model settings;
  • Transformers – contains transformers that are used in APIs (Fractal & spatie/laravel-fractal);
  • ViewComposers – contains view composers that are used in Blade templates.

Frontend

Frontend is powered by simple Vue 3 application with Tailwind CSS styles and a few Tailwind UI components.

Check resources/js directory to see all frontend code.

Tests

This application has tests (Pest) that cover versioned API routes. You can run them with the following command:

php artisan test

Commits history

This repository contains a history of commits that show how the application was built step by step. You can check them to see how Laniakea features were implemented and/or refactored.

License

The MIT License (MIT). Please see License File for more information.