Download the PHP package yggdrasilcloud/core without Composer
On this page you can find all versions of the php package yggdrasilcloud/core. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download yggdrasilcloud/core
More information about yggdrasilcloud/core
Files in yggdrasilcloud/core
Package core
Short Description YggdrasilCloud Core API - Photo management backend with hexagonal architecture
License proprietary
Informations about the package core
YggdrasilCloud API
REST API for photo management built with Domain-Driven Design (DDD) architecture using Symfony 7.3.
Features
- 🏗️ Domain-Driven Design: Clean architecture with bounded contexts
- 📸 Photo Management: Upload, organize, and list photos by folders
- 🔒 File Validation: Configurable file size limits and MIME type restrictions
- 🧪 100% Mutation Coverage: Comprehensive test suite with Infection
- 🐳 Docker Ready: FrankenPHP + PostgreSQL with Docker Compose
- 🚀 CQRS Pattern: Separate commands and queries with Symfony Messenger
Tech Stack
- Framework: Symfony 7.3
- Runtime: FrankenPHP (PHP 8.4 + Caddy)
- Database: PostgreSQL 16
- Testing: PHPUnit 12 + Infection
- Architecture: DDD with CQRS
Project Structure
Getting Started
Prerequisites
- Docker and Docker Compose
- Git
Installation
-
Clone the repository:
-
Start the services:
-
Create the database and run migrations:
- The API is now available at
http://localhost:8000
Optional Packages
YggdrasilCloud uses a modular architecture. Some features are available as optional packages:
Storage S3 (AWS S3 / MinIO)
For S3-compatible storage instead of local filesystem:
Then configure your .env:
See Storage DSN Configuration for more details.
API Endpoints
Health Check
Folders
Photos
Configuration
Environment Variables
Storage DSN Configuration
The storage system uses a flexible DSN-based configuration that allows you to switch between different storage backends (local filesystem, S3, FTP, etc.) by simply changing an environment variable.
DSN Format
Built-in Driver: Local Filesystem
Basic usage:
With custom limits:
Options:
root(required): Base directory for file storagemax_key_length(optional, default: 1024): Maximum total key length in charactersmax_component_length(optional, default: 255): Maximum path component length (filesystem limit)
External Drivers via Bridges
For cloud storage or other backends, install the corresponding bridge package:
AWS S3 / MinIO:
Note: Set your S3 credentials using the standard environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY. Do not include credentials in the DSN.
FTP/FTPS:
Google Cloud Storage:
Bridge Auto-Discovery
Storage bridges are automatically discovered via Symfony's service tag storage.bridge. When you install a bridge package, it registers itself automatically—no manual configuration needed.
Missing Bridge Error:
If you try to use a storage driver without installing its bridge, you'll see:
Creating Custom Bridges
To create your own storage bridge (e.g., for Azure Blob, Dropbox, etc.), implement StorageBridgeInterface and tag your service:
Then use it:
Dependency Injection Configuration
The storage system integrates seamlessly with Symfony's DI container using a factory pattern:
Service Configuration (config/services.yaml):
How it works:
- StorageFactory receives all services tagged with
storage.bridgevia!tagged_iterator - FileStorageInterface is created by calling
StorageFactory::create()with theSTORAGE_DSNenvironment variable - The factory parses the DSN and either:
- Returns a built-in adapter (e.g.,
LocalStorageforlocal://) - Searches registered bridges for external drivers (e.g., S3, FTP)
- Returns a built-in adapter (e.g.,
- The resolved storage adapter is injected wherever
FileStorageInterfaceis type-hinted
Usage in your code:
No need to know which storage backend is used—switch from local to S3 by simply changing STORAGE_DSN!
Optional: Logger Integration
LocalStorage supports optional PSR-3 logging for I/O errors (Monolog, etc.):
When configured, I/O errors (file not found, write failures, etc.) are automatically logged with context.
Development
Run Tests
Code Quality
Database Migrations
Testing
The project has comprehensive test coverage:
- 72 unit tests covering Value Objects, Aggregates, and Services
- 100% Mutation Score Indicator (MSI) with Infection
- 114 assertions ensuring edge cases and boundaries
Test Structure
Run Specific Tests
Architecture Decisions
Why Domain-Driven Design?
- Clear boundaries: Photo context is isolated and can evolve independently
- Business logic in domain: Rules like "photos must be images" are in the domain
- Testability: Domain logic is pure PHP, easy to test without framework
- Flexibility: Can swap infrastructure (Doctrine → another ORM) without touching domain
Why CQRS?
- Separation of concerns: Commands (write) vs Queries (read)
- Scalability: Can optimize read and write models independently
- Event sourcing ready: Commands emit domain events for future event store
Why Value Objects?
- Type safety:
PhotoIdinstead of raw strings prevents errors - Validation: Business rules enforced at construction (filename max 255 chars)
- Immutability: Value objects can't be changed after creation
Why separate repositories for read/write?
- CQRS pattern: Commands use aggregate repositories, queries use read-optimized repositories
- Performance: Read models can be denormalized for faster queries
- Evolution: Read and write models can evolve separately
Domain Concepts
Aggregates
- Photo: Represents an uploaded photo with metadata
- Folder: Groups photos together
Value Objects
- PhotoId / FolderId: UUID v7 identifiers
- FileName: Validated filename (max 255 chars, trims whitespace)
- FolderName: Validated folder name (max 255 chars, non-empty)
- StoredFile: File metadata (path, MIME type, size)
Domain Events
- PhotoUploaded: Emitted when a photo is uploaded
- FolderCreated: Emitted when a folder is created
These events are currently stored in-memory but can be persisted with the Transactional Outbox pattern (see code comments).
Future Enhancements
Documented in Code
- Transactional Outbox Pattern: Store domain events in database for reliable publishing
- Duplicate Detection: Use SHA-256 hash to detect duplicate uploads
- EXIF Metadata: Extract and store camera, location, date taken
Planned Features
- User Authentication: JWT-based authentication
- Authorization: Role-based access control (RBAC)
- Photo Sharing: Share folders with other users
- Search: Full-text search on filenames and EXIF data
- Thumbnails: Generate multiple sizes for responsive images
- Albums: Virtual collections across folders
Docker Services
FrankenPHP (php)
- PHP 8.4 with FrankenPHP (Caddy + PHP)
- Exposed on port 8000
- Hot-reload with volume mount
PostgreSQL (postgres)
- PostgreSQL 16
- Data persisted in
postgres-datavolume - Exposed on port 5432
CORS Configuration
For multi-client support (web, mobile), CORS is configured to accept requests from:
- Web frontend (localhost:5173 in dev, production domain)
- Mobile apps (Android, iOS)
Contributing
Commit Style
Simple, descriptive commit messages (no conventional commits):
Branch Strategy
main: Stable, production-ready code- Feature branches: Create from
main, merge via PR
License
MIT
Related Repositories
- Frontend: YggdrasilCloud/frontend - SvelteKit web application
- Android: (Coming soon)
All versions of core with dependencies
ext-ctype Version *
ext-iconv Version *
ext-mbstring Version *
ankitpokhrel/tus-php Version ^2.4
azjezz/psl Version ^4.2
doctrine/dbal Version ^3.10.3
doctrine/doctrine-bundle Version ^2.18
doctrine/doctrine-migrations-bundle Version ^3.5
doctrine/orm Version ^3.5.2
nelmio/cors-bundle Version ^2.6
runtime/frankenphp-symfony Version ^0.2.0
symfony/console Version 7.3.*
symfony/dotenv Version 7.3.*
symfony/flex Version ^2.8.2
symfony/framework-bundle Version 7.3.*
symfony/messenger Version 7.3.*
symfony/mime Version 7.3.*
symfony/runtime Version 7.3.*
symfony/serializer Version 7.3.*
symfony/uid Version 7.3.*
symfony/validator Version 7.3.*
symfony/yaml Version 7.3.*