Skip to content

Latest commit

Β 

History

History
534 lines (394 loc) Β· 12.1 KB

File metadata and controls

534 lines (394 loc) Β· 12.1 KB

πŸ› οΈ Developer Guide – Nextcloud Vereins-App

πŸ‡©πŸ‡ͺ Deutsch | πŸ‡¬πŸ‡§ English


Deutsch

Dieses Dokument richtet sich an Entwickler, die zur Vereins-App beitragen oder sie erweitern mΓΆchten.

πŸ“‹ Inhaltsverzeichnis

  1. Voraussetzungen
  2. Entwicklungsumgebung einrichten
  3. Projektstruktur
  4. Architektur
  5. Backend (PHP)
  6. Frontend (Vue 3)
  7. Testing
  8. Deployment
  9. Contributing
  10. Code Style

πŸ”§ Voraussetzungen

Systemanforderungen

Komponente Version Zweck
PHP β‰₯ 8.0 Backend
Node.js β‰₯ 18.x Frontend Build
npm β‰₯ 9.x Package Manager
Composer β‰₯ 2.x PHP Dependencies
Nextcloud β‰₯ 28.0 App-Plattform
SQLite/MySQL/PostgreSQL - Datenbank

Empfohlene Tools

  • VS Code mit Extensions: PHP Intelephense, Volar (Vue 3), ESLint
  • Git fΓΌr Versionskontrolle
  • Postman oder curl fΓΌr API-Tests

πŸš€ Entwicklungsumgebung einrichten

1. Repository klonen

cd /path/to/nextcloud/apps
git clone https://github.com/Wacken2012/nextcloud-verein.git verein
cd verein

2. Dependencies installieren

composer install    # PHP Dependencies
npm install         # Frontend Dependencies

3. Frontend bauen

npm run watch       # Watch-Modus (Entwicklung)
npm run build       # Production Build

4. App aktivieren

sudo -u www-data php /var/www/html/nextcloud/occ app:enable verein

πŸ“ Projektstruktur

verein/
β”œβ”€β”€ appinfo/
β”‚   β”œβ”€β”€ database.xml      # Datenbankschema
β”‚   β”œβ”€β”€ info.xml          # App-Metadaten
β”‚   └── routes.php        # API-Routen
β”œβ”€β”€ docs/                 # Dokumentation
β”œβ”€β”€ js/
β”‚   β”œβ”€β”€ components/       # Vue-Komponenten
β”‚   β”œβ”€β”€ dist/             # Kompilierte Assets
β”‚   β”œβ”€β”€ App.vue           # Haupt-Vue-App
β”‚   β”œβ”€β”€ main.js           # Entry Point
β”‚   └── api.js            # API-Client
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ Controller/       # HTTP Controller
β”‚   β”œβ”€β”€ Db/               # Entities & Mapper
β”‚   β”œβ”€β”€ Middleware/       # Request Middleware
β”‚   β”œβ”€β”€ Service/          # Business Logic
β”‚   └── Settings/         # Admin Settings
β”œβ”€β”€ templates/            # PHP Templates
β”œβ”€β”€ tests/                # Unit & Integration Tests
└── vendor/               # Composer Dependencies

πŸ—οΈ Architektur

Schichtenmodell

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           Frontend (Vue 3)          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚           Controller (PHP)          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚         Service (Business Logic)    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚           Mapper/DB (ORM)           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚          Nextcloud Core (OCP)       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🐘 Backend (PHP)

Controller erstellen

<?php
namespace OCA\Verein\Controller;

use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse;

class ExampleController extends Controller {
    /**
     * @NoAdminRequired
     * @NoCSRFRequired
     */
    public function index(): JSONResponse {
        return new JSONResponse(['status' => 'ok']);
    }
}

Annotations

Annotation Bedeutung
@NoAdminRequired Nicht-Admins dΓΌrfen zugreifen
@NoCSRFRequired Kein CSRF-Token nΓΆtig
@PublicPage Γ–ffentlich zugΓ€nglich

RBAC-Berechtigungen

use OCA\Verein\Attributes\RequirePermission;

#[RequirePermission('members.create')]
public function create(): JSONResponse {
    // Nur mit members.create Berechtigung
}

⚑ Frontend (Vue 3)

Komponenten-Struktur

<template>
  <NcButton @click="handleClick">
    {{ t('verein', 'Klick mich') }}
  </NcButton>
</template>

<script>
import { NcButton } from '@nextcloud/vue'
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'

export default {
  name: 'ExampleComponent',
  methods: {
    async handleClick() {
      const { data } = await axios.get(generateUrl('/apps/verein/api'))
    }
  }
}
</script>

Notifications

import { success, error } from '../notify.js'

success('Erfolgreich gespeichert')
error('Fehler beim Speichern')

πŸ§ͺ Testing

# Alle Tests
composer test

# Nur Unit Tests
./vendor/bin/phpunit --testsuite Unit

# Schnelle Tests (Export, Validation)
./vendor/bin/phpunit --testsuite Fast

# Mit Coverage
./vendor/bin/phpunit --coverage-html coverage/

🚒 Deployment

# Deploy Script
./scripts/deploy-to-nextcloud.sh

# Manuell
rsync -av --exclude='node_modules' --exclude='.git' \
  ./ /var/www/html/nextcloud/apps/verein/

🀝 Contributing

  1. Fork & Branch erstellen: git checkout -b feature/mein-feature
  2. Γ„nderungen committen (Conventional Commits)
  3. Pull Request gegen develop Branch

Commit-Format

<type>(<scope>): <description>

feat(members): Add bulk import
fix(export): Correct PDF widths
docs(api): Add OpenAPI spec

πŸ“ Code Style

  • PHP: PSR-12 mit php-cs-fixer
  • JavaScript: ESLint mit Nextcloud-Config
  • Typisierung in PHP (Type Hints, Return Types)
  • Tests fΓΌr neue Features

English

This document is intended for developers who want to contribute to or extend the Vereins-App.

πŸ“‹ Table of Contents

  1. Prerequisites
  2. Development Environment Setup
  3. Project Structure
  4. Architecture
  5. Backend (PHP)
  6. Frontend (Vue 3)
  7. Testing
  8. Deployment
  9. Contributing
  10. Code Style

πŸ”§ Prerequisites

System Requirements

Component Version Purpose
PHP β‰₯ 8.0 Backend
Node.js β‰₯ 18.x Frontend Build
npm β‰₯ 9.x Package Manager
Composer β‰₯ 2.x PHP Dependencies
Nextcloud β‰₯ 28.0 App Platform
SQLite/MySQL/PostgreSQL - Database

Recommended Tools

  • VS Code with Extensions: PHP Intelephense, Volar (Vue 3), ESLint
  • Git for version control
  • Postman or curl for API testing

πŸš€ Development Environment Setup

1. Clone Repository

cd /path/to/nextcloud/apps
git clone https://github.com/Wacken2012/nextcloud-verein.git verein
cd verein

2. Install Dependencies

composer install    # PHP Dependencies
npm install         # Frontend Dependencies

3. Build Frontend

npm run watch       # Watch mode (development)
npm run build       # Production build

4. Enable App

sudo -u www-data php /var/www/html/nextcloud/occ app:enable verein

πŸ“ Project Structure

verein/
β”œβ”€β”€ appinfo/
β”‚   β”œβ”€β”€ database.xml      # Database schema
β”‚   β”œβ”€β”€ info.xml          # App metadata
β”‚   └── routes.php        # API routes
β”œβ”€β”€ docs/                 # Documentation
β”œβ”€β”€ js/
β”‚   β”œβ”€β”€ components/       # Vue components
β”‚   β”œβ”€β”€ dist/             # Compiled assets
β”‚   β”œβ”€β”€ App.vue           # Main Vue app
β”‚   β”œβ”€β”€ main.js           # Entry point
β”‚   └── api.js            # API client
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ Controller/       # HTTP controllers
β”‚   β”œβ”€β”€ Db/               # Entities & mappers
β”‚   β”œβ”€β”€ Middleware/       # Request middleware
β”‚   β”œβ”€β”€ Service/          # Business logic
β”‚   └── Settings/         # Admin settings
β”œβ”€β”€ templates/            # PHP templates
β”œβ”€β”€ tests/                # Unit & integration tests
└── vendor/               # Composer dependencies

πŸ—οΈ Architecture

Layer Model

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           Frontend (Vue 3)          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚           Controller (PHP)          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚         Service (Business Logic)    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚           Mapper/DB (ORM)           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚          Nextcloud Core (OCP)       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🐘 Backend (PHP)

Creating Controllers

<?php
namespace OCA\Verein\Controller;

use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse;

class ExampleController extends Controller {
    /**
     * @NoAdminRequired
     * @NoCSRFRequired
     */
    public function index(): JSONResponse {
        return new JSONResponse(['status' => 'ok']);
    }
}

Annotations

Annotation Meaning
@NoAdminRequired Non-admins can access
@NoCSRFRequired No CSRF token required
@PublicPage Publicly accessible

RBAC Permissions

use OCA\Verein\Attributes\RequirePermission;

#[RequirePermission('members.create')]
public function create(): JSONResponse {
    // Only with members.create permission
}

⚑ Frontend (Vue 3)

Component Structure

<template>
  <NcButton @click="handleClick">
    {{ t('verein', 'Click me') }}
  </NcButton>
</template>

<script>
import { NcButton } from '@nextcloud/vue'
import axios from '@nextcloud/axios'
import { generateUrl } from '@nextcloud/router'

export default {
  name: 'ExampleComponent',
  methods: {
    async handleClick() {
      const { data } = await axios.get(generateUrl('/apps/verein/api'))
    }
  }
}
</script>

Notifications

import { success, error } from '../notify.js'

success('Successfully saved')
error('Error saving')

πŸ§ͺ Testing

# All tests
composer test

# Unit tests only
./vendor/bin/phpunit --testsuite Unit

# Fast tests (Export, Validation)
./vendor/bin/phpunit --testsuite Fast

# With coverage
./vendor/bin/phpunit --coverage-html coverage/

🚒 Deployment

# Deploy script
./scripts/deploy-to-nextcloud.sh

# Manual
rsync -av --exclude='node_modules' --exclude='.git' \
  ./ /var/www/html/nextcloud/apps/verein/

🀝 Contributing

  1. Fork & create branch: git checkout -b feature/my-feature
  2. Commit changes (Conventional Commits)
  3. Pull Request against develop branch

Commit Format

<type>(<scope>): <description>

feat(members): Add bulk import
fix(export): Correct PDF widths
docs(api): Add OpenAPI spec

πŸ“ Code Style

  • PHP: PSR-12 with php-cs-fixer
  • JavaScript: ESLint with Nextcloud config
  • Type hints in PHP (Type Hints, Return Types)
  • Tests for new features

πŸ“š Further Resources / WeiterfΓΌhrende Ressourcen


Letzte Aktualisierung / Last updated: 30. November 2025