Skip to content

Commit dbcf777

Browse files
Simplify workflow, enhance README with step-by-step guide, remove packagist script
Co-Authored-By: Max Prilutskiy <maks.prilutskiy@gmail.com>
1 parent b6d4f7d commit dbcf777

File tree

3 files changed

+68
-114
lines changed

3 files changed

+68
-114
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
tools: composer:v2
2828

2929
- name: Validate composer.json
30-
run: composer validate --no-check-publish
30+
run: composer validate --strict
3131

3232
- name: Install dependencies
3333
run: composer install --prefer-dist
@@ -100,12 +100,3 @@ jobs:
100100
run: |
101101
git tag v${{ steps.bump_version.outputs.new_version }}
102102
git push origin v${{ steps.bump_version.outputs.new_version }}
103-
104-
- name: Publish to Packagist
105-
if: success() && (github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch')
106-
run: |
107-
php scripts/packagist-publish.php
108-
env:
109-
PACKAGIST_USERNAME: lingodotdev
110-
PACKAGIST_API_TOKEN: ${{ secrets.PACKAGIST_API_TOKEN }}
111-
PACKAGE_NAME: lingodotdev/sdk

README.md

Lines changed: 67 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,73 @@ composer require lingodotdev/sdk
1717
- GuzzleHttp Client
1818
- Respect Validation
1919

20+
## Getting Started
21+
22+
### Creating a New PHP Project with Lingo.dev SDK
23+
24+
Follow these steps to create a new PHP project that uses the Lingo.dev SDK:
25+
26+
1. **Create a project directory**:
27+
```bash
28+
mkdir my-lingo-project
29+
cd my-lingo-project
30+
```
31+
32+
2. **Initialize Composer**:
33+
```bash
34+
composer init --name=your-vendor/your-project --description="Your project description" --type=project --require="php:^8.1" --author="Your Name <your.email@example.com>"
35+
```
36+
37+
3. **Add Lingo.dev SDK as a dependency**:
38+
```bash
39+
composer require lingodotdev/sdk
40+
```
41+
42+
4. **Create a simple PHP script** (index.php):
43+
```php
44+
<?php
45+
46+
require 'vendor/autoload.php';
47+
48+
use LingoDotDev\Sdk\LingoDotDevEngine;
49+
50+
// Get API key from environment variable or command line
51+
$apiKey = getenv('LINGODOTDEV_API_KEY') ?: $argv[1] ?? null;
52+
53+
if (!$apiKey) {
54+
echo "Error: API key is required. Set LINGODOTDEV_API_KEY environment variable or pass it as a command-line argument.\n";
55+
exit(1);
56+
}
57+
58+
// Initialize the SDK
59+
$engine = new LingoDotDevEngine([
60+
'apiKey' => $apiKey,
61+
]);
62+
63+
// Make your first localization call
64+
try {
65+
$result = $engine->localizeText('Hello, this is my first localization with Lingo.dev!', [
66+
'sourceLocale' => 'en',
67+
'targetLocale' => 'es',
68+
]);
69+
70+
echo "Original: Hello, this is my first localization with Lingo.dev!\n";
71+
echo "Translated to Spanish: $result\n";
72+
} catch (\Exception $e) {
73+
echo "Error: " . $e->getMessage() . "\n";
74+
}
75+
```
76+
77+
5. **Run your script**:
78+
```bash
79+
# Option 1: Pass API key as command-line argument
80+
php index.php your-api-key-here
81+
82+
# Option 2: Set environment variable and run
83+
export LINGODOTDEV_API_KEY=your-api-key-here
84+
php index.php
85+
```
86+
2087
## Basic Usage
2188

2289
### Initialize the SDK
@@ -141,27 +208,13 @@ $engine->localizeText('Hello, world!', [
141208
});
142209
```
143210

144-
## Advanced Configuration
145-
146-
You can customize the SDK behavior with additional configuration options:
147-
148-
```php
149-
$engine = new LingoDotDevEngine([
150-
'apiKey' => 'your-api-key',
151-
'apiUrl' => 'https://custom-engine.lingo.dev', // Custom API URL
152-
'batchSize' => 50, // Custom batch size (1-250)
153-
'idealBatchItemSize' => 500 // Custom batch item size (1-2500)
154-
]);
155-
```
156-
157211
## Release Process
158212

159213
The SDK uses semantic versioning (MAJOR.MINOR.PATCH) and is automatically published to Packagist when changes are merged to the main branch. The release process includes:
160214

161215
1. Running tests to ensure code quality
162216
2. Automatically bumping the patch version
163217
3. Creating a git tag for the new version
164-
4. Publishing the package to Packagist
165218

166219
Packagist automatically fetches new versions from the GitHub repository when tags are pushed, making the new version immediately available for installation via Composer.
167220

scripts/packagist-publish.php

Lines changed: 0 additions & 90 deletions
This file was deleted.

0 commit comments

Comments
 (0)