Skip to content

Commit 6370cfa

Browse files
committed
init
0 parents  commit 6370cfa

37 files changed

Lines changed: 1895 additions & 0 deletions
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Check deployed package
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_run:
6+
workflows: ["Release-plz"]
7+
types:
8+
- completed
9+
branches:
10+
- main
11+
12+
jobs:
13+
check-deployed-package:
14+
name: Check deployed package
15+
runs-on: ubuntu-latest
16+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v3
21+
22+
- name: Wait for package to propagate
23+
run: sleep 60
24+
25+
- name: Make run script executable
26+
run: chmod +x check-deployed-package/run.sh
27+
28+
- name: Check deployed package
29+
env:
30+
LOGDASH_API_KEY: ${{ secrets.LOGDASH_API_KEY }}
31+
run: ./check-deployed-package/run.sh

.github/workflows/ci.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ "main", "develop" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
php: ['8.1', '8.2', '8.3', '8.4']
15+
16+
name: PHP ${{ matrix.php }} Tests
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Setup PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: ${{ matrix.php }}
26+
extensions: json, mbstring, zip
27+
tools: composer
28+
29+
- name: Cache Composer dependencies
30+
uses: actions/cache@v3
31+
with:
32+
path: ~/.composer/cache
33+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
34+
restore-keys: ${{ runner.os }}-composer-
35+
36+
- name: Install dependencies
37+
run: composer install --no-interaction --no-progress --ansi
38+
39+
- name: Run syntax check
40+
run: find src -name "*.php" -exec php -l {} \;
41+
42+
- name: Run basic test
43+
run: php test.php
44+
45+
- name: Run PHPStan (if available)
46+
run: |
47+
if [ -f vendor/bin/phpstan ]; then
48+
vendor/bin/phpstan analyse --no-progress
49+
else
50+
echo "PHPStan not available, skipping static analysis"
51+
fi
52+
53+
- name: Run PHP CodeSniffer (if available)
54+
run: |
55+
if [ -f vendor/bin/phpcs ]; then
56+
vendor/bin/phpcs
57+
else
58+
echo "PHP CodeSniffer not available, skipping code style check"
59+
fi
60+
61+
- name: Run PHPUnit tests (if available)
62+
run: |
63+
if [ -f vendor/bin/phpunit ]; then
64+
vendor/bin/phpunit
65+
else
66+
echo "PHPUnit not available, skipping unit tests"
67+
fi

.github/workflows/release-plz.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Release
2+
3+
permissions:
4+
contents: write
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
11+
jobs:
12+
release:
13+
name: Release PHP Package
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Setup PHP
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: '8.1'
27+
extensions: mbstring, xml, curl, zip, json
28+
tools: composer
29+
30+
- name: Install dependencies
31+
run: composer install --no-dev --optimize-autoloader
32+
33+
- name: Run tests
34+
run: composer test
35+
36+
- name: Run static analysis
37+
run: composer phpstan
38+
39+
- name: Check code style
40+
run: composer cs
41+
42+
- name: Create release
43+
id: create_release
44+
uses: actions/create-release@v1
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
with:
48+
tag_name: v${{ github.run_number }}
49+
release_name: Release v${{ github.run_number }}
50+
draft: false
51+
prerelease: false
52+
53+
- name: Publish to Packagist
54+
# This would require Packagist webhook or manual submission
55+
# For now, we'll just create the GitHub release
56+
run: echo "Package published to GitHub. Submit to Packagist manually or configure webhook."

.github/workflows/release.yml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
name: Release PHP Package
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
env:
10+
COMPOSER_ARGS: "--no-interaction --no-progress --ansi"
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
php: ['8.1', '8.2', '8.3', '8.4']
18+
19+
name: PHP ${{ matrix.php }} Tests
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Setup PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: ${{ matrix.php }}
29+
extensions: json, mbstring, zip
30+
tools: composer
31+
32+
- name: Cache Composer dependencies
33+
uses: actions/cache@v3
34+
with:
35+
path: ~/.composer/cache
36+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
37+
restore-keys: ${{ runner.os }}-composer-
38+
39+
- name: Install dependencies
40+
run: composer install ${{ env.COMPOSER_ARGS }}
41+
42+
- name: Run PHPStan
43+
run: vendor/bin/phpstan analyse --no-progress
44+
45+
- name: Run PHP CodeSniffer
46+
run: vendor/bin/phpcs
47+
48+
- name: Run PHPUnit tests
49+
run: vendor/bin/phpunit
50+
51+
release:
52+
needs: test
53+
runs-on: ubuntu-latest
54+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
55+
56+
steps:
57+
- name: Checkout code
58+
uses: actions/checkout@v4
59+
with:
60+
fetch-depth: 0
61+
62+
- name: Setup PHP
63+
uses: shivammathur/setup-php@v2
64+
with:
65+
php-version: '8.3'
66+
extensions: json, mbstring, zip
67+
tools: composer
68+
69+
- name: Install dependencies
70+
run: composer install ${{ env.COMPOSER_ARGS }} --no-dev
71+
72+
- name: Check if version changed
73+
id: version-check
74+
run: |
75+
# Get current version from composer.json
76+
CURRENT_VERSION=$(php -r "echo json_decode(file_get_contents('composer.json'))->version ?? 'unknown';")
77+
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
78+
79+
# Check if this version already has a git tag
80+
if git tag -l "v$CURRENT_VERSION" | grep -q "v$CURRENT_VERSION"; then
81+
echo "should_release=false" >> $GITHUB_OUTPUT
82+
echo "Version $CURRENT_VERSION already released"
83+
else
84+
echo "should_release=true" >> $GITHUB_OUTPUT
85+
echo "New version $CURRENT_VERSION ready for release"
86+
fi
87+
88+
- name: Create GitHub Release
89+
if: steps.version-check.outputs.should_release == 'true'
90+
uses: softprops/action-gh-release@v1
91+
with:
92+
tag_name: v${{ steps.version-check.outputs.current_version }}
93+
name: v${{ steps.version-check.outputs.current_version }}
94+
generate_release_notes: true
95+
env:
96+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
97+
98+
- name: Publish to Packagist
99+
if: steps.version-check.outputs.should_release == 'true'
100+
run: |
101+
echo "Package will be automatically published to Packagist when the GitHub release is created"
102+
echo "Make sure your package is registered at https://packagist.org and has the GitHub webhook configured"
103+
104+
package-test:
105+
needs: release
106+
runs-on: ubuntu-latest
107+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
108+
109+
steps:
110+
- name: Checkout code
111+
uses: actions/checkout@v4
112+
113+
- name: Wait for Packagist
114+
run: |
115+
echo "Waiting 30 seconds for Packagist to update..."
116+
sleep 30
117+
118+
- name: Test deployed package
119+
env:
120+
LOGDASH_API_KEY: ${{ secrets.LOGDASH_API_KEY }}
121+
run: |
122+
cd check-deployed-package
123+
chmod +x run.sh
124+
./run.sh

.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Dependencies
2+
/vendor/
3+
composer.lock
4+
5+
# IDE
6+
.idea/
7+
.vscode/
8+
*.swp
9+
*.swo
10+
11+
# OS
12+
.DS_Store
13+
Thumbs.db
14+
15+
# Test coverage
16+
.phpunit.result.cache
17+
coverage/
18+
phpunit.xml.local
19+
20+
# Logs
21+
*.log
22+
23+
# Environment
24+
.env
25+
.env.local
26+
27+
# Cache
28+
.phpstan.cache

CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
## [1.0.0] - 2025-06-27
11+
12+
### Added
13+
- Initial release of LogDash PHP SDK
14+
- Logger with multiple log levels (error, warn, info, http, verbose, debug, silly)
15+
- Metrics API with set and mutate operations
16+
- HTTP synchronization for logs and metrics
17+
- Support for local-only logging when no API key is provided
18+
- Colored console output for improved debugging
19+
- Non-blocking error handling for production environments
20+
- PSR-4 autoloading support
21+
- Comprehensive documentation and examples
22+
23+
### Features
24+
- Zero-configuration setup
25+
- Real-time cloud synchronization
26+
- Framework-agnostic design
27+
- PHP 8.1+ compatibility
28+
- Guzzle HTTP client integration
29+
- PHPUnit test suite
30+
- PHPStan static analysis
31+
- PHP CodeSniffer integration

Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM php:8.3-cli
2+
3+
# Install system dependencies
4+
RUN apt-get update && apt-get install -y \
5+
git \
6+
unzip \
7+
libzip-dev \
8+
&& docker-php-ext-install zip
9+
10+
# Install Composer
11+
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
12+
13+
# Set working directory
14+
WORKDIR /app
15+
16+
# Copy composer files
17+
COPY composer.json composer.lock* ./
18+
19+
# Install PHP dependencies
20+
RUN composer install --no-dev --optimize-autoloader
21+
22+
# Copy source code
23+
COPY . .
24+
25+
# Set permissions
26+
RUN chown -R www-data:www-data /app
27+
28+
# Run tests by default
29+
CMD ["php", "examples.php"]

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 LogDash
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)