Skip to content

Commit 221696b

Browse files
authored
Merge pull request #2 from logtide-dev/feat/restructure
Feat/restructure
2 parents 79b3993 + d70f4b8 commit 221696b

File tree

131 files changed

+10460
-1854
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+10460
-1854
lines changed

.github/workflows/ci.yml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main, develop]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
# ====================
14+
# Unit Tests (PHP matrix)
15+
# ====================
16+
test:
17+
name: Tests (PHP ${{ matrix.php }})
18+
runs-on: ubuntu-latest
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
php: ['8.1', '8.2', '8.3', '8.4']
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Setup PHP
29+
uses: shivammathur/setup-php@v2
30+
with:
31+
php-version: ${{ matrix.php }}
32+
extensions: curl, json, mbstring
33+
coverage: xdebug
34+
35+
- name: Get Composer cache directory
36+
id: composer-cache
37+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
38+
39+
- name: Cache Composer dependencies
40+
uses: actions/cache@v4
41+
with:
42+
path: ${{ steps.composer-cache.outputs.dir }}
43+
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('**/composer.json') }}
44+
restore-keys: ${{ runner.os }}-composer-${{ matrix.php }}-
45+
46+
- name: Install dependencies
47+
run: composer install --prefer-dist --no-progress
48+
49+
- name: Run tests
50+
run: composer test
51+
52+
# ====================
53+
# Static Analysis (PHPStan)
54+
# ====================
55+
phpstan:
56+
name: Static Analysis
57+
runs-on: ubuntu-latest
58+
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v4
62+
63+
- name: Setup PHP
64+
uses: shivammathur/setup-php@v2
65+
with:
66+
php-version: '8.3'
67+
extensions: curl, json, mbstring
68+
69+
- name: Get Composer cache directory
70+
id: composer-cache
71+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
72+
73+
- name: Cache Composer dependencies
74+
uses: actions/cache@v4
75+
with:
76+
path: ${{ steps.composer-cache.outputs.dir }}
77+
key: ${{ runner.os }}-composer-8.3-${{ hashFiles('**/composer.json') }}
78+
restore-keys: ${{ runner.os }}-composer-8.3-
79+
80+
- name: Install dependencies
81+
run: composer install --prefer-dist --no-progress
82+
83+
- name: Run PHPStan
84+
run: composer phpstan
85+
86+
# ====================
87+
# Code Style (PHPCS)
88+
# ====================
89+
phpcs:
90+
name: Code Style
91+
runs-on: ubuntu-latest
92+
93+
steps:
94+
- name: Checkout
95+
uses: actions/checkout@v4
96+
97+
- name: Setup PHP
98+
uses: shivammathur/setup-php@v2
99+
with:
100+
php-version: '8.3'
101+
extensions: curl, json, mbstring
102+
103+
- name: Get Composer cache directory
104+
id: composer-cache
105+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
106+
107+
- name: Cache Composer dependencies
108+
uses: actions/cache@v4
109+
with:
110+
path: ${{ steps.composer-cache.outputs.dir }}
111+
key: ${{ runner.os }}-composer-8.3-${{ hashFiles('**/composer.json') }}
112+
restore-keys: ${{ runner.os }}-composer-8.3-
113+
114+
- name: Install dependencies
115+
run: composer install --prefer-dist --no-progress
116+
117+
- name: Check code style
118+
run: composer cs

.github/workflows/publish.yml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Publish to Packagist
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
release:
8+
types: [published]
9+
workflow_dispatch:
10+
inputs:
11+
tag:
12+
description: 'Tag to publish (e.g., v0.7.0)'
13+
required: true
14+
type: string
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
# ====================
21+
# Validate & Extract version
22+
# ====================
23+
prepare:
24+
name: Prepare Release
25+
runs-on: ubuntu-latest
26+
outputs:
27+
version: ${{ steps.version.outputs.version }}
28+
steps:
29+
- name: Extract version from tag
30+
id: version
31+
run: |
32+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
33+
VERSION="${{ github.event.inputs.tag }}"
34+
elif [ "${{ github.event_name }}" = "release" ]; then
35+
VERSION="${{ github.event.release.tag_name }}"
36+
else
37+
VERSION=${GITHUB_REF#refs/tags/}
38+
fi
39+
VERSION=${VERSION#v}
40+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
41+
echo "Version: ${VERSION}"
42+
43+
# ====================
44+
# Build & Test
45+
# ====================
46+
validate:
47+
name: Build & Test
48+
runs-on: ubuntu-latest
49+
needs: prepare
50+
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@v4
54+
55+
- name: Setup PHP
56+
uses: shivammathur/setup-php@v2
57+
with:
58+
php-version: '8.3'
59+
extensions: curl, json, mbstring
60+
61+
- name: Install dependencies
62+
run: composer install --prefer-dist --no-progress
63+
64+
- name: Run tests
65+
run: composer test
66+
67+
- name: Run PHPStan
68+
run: composer phpstan
69+
70+
- name: Check code style
71+
run: composer cs
72+
73+
# ====================
74+
# Publish all packages to Packagist
75+
# ====================
76+
publish:
77+
name: Publish to Packagist
78+
runs-on: ubuntu-latest
79+
needs: [prepare, validate]
80+
81+
steps:
82+
- name: Checkout
83+
uses: actions/checkout@v4
84+
85+
- name: Setup PHP
86+
uses: shivammathur/setup-php@v2
87+
with:
88+
php-version: '8.3'
89+
extensions: curl, json, mbstring
90+
91+
- name: Set version in all packages
92+
run: |
93+
VERSION="${{ needs.prepare.outputs.version }}"
94+
echo "Setting version to ${VERSION} in all packages..."
95+
96+
for file in composer.json packages/*/composer.json; do
97+
if [ -f "$file" ]; then
98+
php -r "
99+
\$pkg = json_decode(file_get_contents('$file'), true);
100+
\$pkg['version'] = '${VERSION}';
101+
file_put_contents('$file', json_encode(\$pkg, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . \"\n\");
102+
"
103+
echo " Updated $file to ${VERSION}"
104+
fi
105+
done
106+
107+
- name: Notify Packagist
108+
run: |
109+
echo "Notifying Packagist to re-index repository..."
110+
curl -s -X POST \
111+
"https://packagist.org/api/update-package?username=logtide&apiToken=${{ secrets.PACKAGIST_TOKEN }}" \
112+
-d '{"repository":{"url":"https://github.com/logtide-dev/logtide-php"}}' \
113+
|| echo "Warning: Failed to notify Packagist"
114+
115+
- name: Create publish summary
116+
run: |
117+
VERSION="${{ needs.prepare.outputs.version }}"
118+
echo "## Packagist Packages Published" >> $GITHUB_STEP_SUMMARY
119+
echo "" >> $GITHUB_STEP_SUMMARY
120+
echo "Version: **${VERSION}**" >> $GITHUB_STEP_SUMMARY
121+
echo "" >> $GITHUB_STEP_SUMMARY
122+
echo "| Package | Install Command |" >> $GITHUB_STEP_SUMMARY
123+
echo "|---------|-----------------|" >> $GITHUB_STEP_SUMMARY
124+
echo "| logtide/logtide | \`composer require logtide/logtide:${VERSION}\` |" >> $GITHUB_STEP_SUMMARY
125+
echo "| logtide/logtide-laravel | \`composer require logtide/logtide-laravel:${VERSION}\` |" >> $GITHUB_STEP_SUMMARY
126+
echo "| logtide/logtide-symfony | \`composer require logtide/logtide-symfony:${VERSION}\` |" >> $GITHUB_STEP_SUMMARY
127+
echo "| logtide/logtide-slim | \`composer require logtide/logtide-slim:${VERSION}\` |" >> $GITHUB_STEP_SUMMARY
128+
echo "| logtide/logtide-wordpress | \`composer require logtide/logtide-wordpress:${VERSION}\` |" >> $GITHUB_STEP_SUMMARY

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
.phpunit.result.cache
66
composer.lock
77
.DS_Store
8+
/.plans/

CHANGELOG.md

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,71 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.7.0] - 2026-03-06
9+
10+
### Added
11+
12+
#### Monorepo Structure
13+
- Restructured as Composer monorepo with 5 packages under `packages/*`
14+
- Unified test suite with PHPUnit 10.5 (265 tests, 570 assertions)
15+
- PHPStan level 8 static analysis across all packages
16+
- PSR-12 code style enforcement with PHP_CodeSniffer
17+
18+
#### Core (`logtide/logtide`)
19+
- `LogtideSdk` - static entry point for SDK initialization
20+
- `ClientBuilder` - fluent client construction with sensible defaults
21+
- `Client` - capture logs, errors, breadcrumbs, and spans
22+
- `Hub` - global singleton for convenient access across your app
23+
- `Scope` - per-request context isolation with tags, extras, and breadcrumbs
24+
- `BatchTransport` - automatic batching with retry logic and circuit breaker
25+
- `HttpTransport` and `OtlpHttpTransport` for log and span delivery
26+
- `CurlHttpClient` and `GuzzleHttpClient` HTTP client implementations
27+
- DSN parsing, error serialization, trace ID generation
28+
- W3C Trace Context (`traceparent`) propagation
29+
- Breadcrumb buffer with configurable max size
30+
- Monolog handlers: `LogtideHandler` and `BreadcrumbHandler`
31+
- PSR-15 middleware for generic HTTP request tracing
32+
- Global helper functions (`\LogTide\init()`, `\LogTide\captureException()`, etc.)
33+
- Built-in integrations: Request, Environment, ExceptionListener, ErrorListener, FatalErrorListener
34+
35+
#### Laravel (`logtide/logtide-laravel`)
36+
- `LogtideServiceProvider` with auto-discovery and publishable config
37+
- `LogtideMiddleware` for automatic request tracing
38+
- `LogChannel` for Laravel logging integration
39+
- `LogtideFacade` for static access
40+
- Breadcrumb integrations: DB queries, cache operations, queue jobs
41+
42+
#### Symfony (`logtide/logtide-symfony`)
43+
- `LogtideBundle` with DI extension and semantic configuration
44+
- `RequestSubscriber` for automatic HTTP request tracing
45+
- `ConsoleSubscriber` for CLI command tracing
46+
- `SymfonyIntegration` and `DoctrineIntegration` for breadcrumbs
47+
48+
#### Slim (`logtide/logtide-slim`)
49+
- `LogtideMiddleware` - PSR-15 middleware for request tracing
50+
- `LogtideErrorMiddleware` - error capture with full request context
51+
- Automatic route pattern resolution from Slim routing
52+
53+
#### WordPress (`logtide/logtide-wordpress`)
54+
- `LogtideWordPress` - static initializer with WordPress hook registration
55+
- Lifecycle hooks: `wp_loaded`, `shutdown`, `wp_die_handler`, `wp_redirect`, `wp_mail`
56+
- `WordPressIntegration` - PHP error handler integration
57+
- `DatabaseIntegration` - slow query breadcrumbs via `$wpdb`
58+
- `HttpApiIntegration` - outgoing HTTP request breadcrumbs
59+
- Multisite support (blog switch tracking, plugin activation/deactivation)
60+
61+
#### CI/CD
62+
- GitHub Actions CI: PHPUnit tests, PHPStan, PHPCS on push/PR to `main`/`develop`
63+
- GitHub Actions publish: Packagist publish on tag `v*.*.*` or manual dispatch
64+
- PHP version matrix: 8.1, 8.2, 8.3, 8.4
65+
- Branch model: `develop``main`, hotfix directly to `main`
66+
67+
#### Documentation
68+
- README for every package with badges, quick start, API reference
69+
- Root README with package table, architecture diagram, development guide
70+
- Contributing guide, Code of Conduct, Changelog
71+
- Branch protection documentation (`.github/BRANCH_PROTECTION.md`)
72+
873
## [0.1.0] - 2026-01-13
974

1075
### Added
@@ -27,4 +92,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2792
- PSR-15 middleware for Slim, Mezzio, and other frameworks
2893
- Full PHP 8.1+ support with strict types and enums
2994

30-
[0.1.0]: https://github.com/logtide-dev/logtide-sdk-php/releases/tag/v0.1.0
95+
[0.7.0]: https://github.com/logtide-dev/logtide-php/releases/tag/v0.7.0
96+
[0.1.0]: https://github.com/logtide-dev/logtide-php/releases/tag/v0.1.0

0 commit comments

Comments
 (0)