Skip to content

Commit d62642f

Browse files
authored
Merge pull request #50 from mesilov/dev
Fix errors in integration scenario
2 parents e8aae56 + f93ee6c commit d62642f

File tree

29 files changed

+455
-454
lines changed

29 files changed

+455
-454
lines changed

.env

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@
1212
#
1313
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
1414
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
15-
DATABASE_HOST=
16-
DATABASE_USER=
17-
DATABASE_PASSWORD=
18-
DATABASE_NAME=
15+
16+
# Database configuration for functional tests
17+
DATABASE_HOST=database
18+
DATABASE_USER=b24phpLibTest
19+
DATABASE_PASSWORD=b24phpLibTest
20+
DATABASE_NAME=b24phpLibTest
21+
22+
# PostgreSQL Docker configuration (aligned with docker-compose.yaml defaults)
23+
POSTGRES_VERSION=16
24+
POSTGRES_DB=b24phpLibTest
25+
POSTGRES_USER=b24phpLibTest
26+
POSTGRES_PASSWORD=b24phpLibTest

.env.example

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Example environment configuration for bitrix24-php-lib
2+
# Copy this file to .env and adjust values as needed
3+
4+
# Database configuration for functional tests
5+
# These values should match your Docker Compose PostgreSQL service
6+
DATABASE_HOST=database
7+
DATABASE_USER=b24phpLibTest
8+
DATABASE_PASSWORD=b24phpLibTest
9+
DATABASE_NAME=b24phpLibTest
10+
11+
# PostgreSQL Docker configuration (aligned with docker-compose.yaml defaults)
12+
POSTGRES_VERSION=16
13+
POSTGRES_DB=b24phpLibTest
14+
POSTGRES_USER=b24phpLibTest
15+
POSTGRES_PASSWORD=b24phpLibTest
16+
17+
# For local development, you can override these values:
18+
# DATABASE_HOST=localhost
19+
# DATABASE_USER=your_local_user
20+
# DATABASE_PASSWORD=your_local_password
21+
# DATABASE_NAME=your_local_db

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## 0.1.1
2+
### Added
3+
- Change php version requirements — [#44](https://github.com/mesilov/bitrix24-php-lib/pull/44)
4+
5+
## 0.1.0
6+
7+
### By [@mesilov](https://github.com/mesilov)
8+
- Add initial project setup with CI configuration — [#2](https://github.com/mesilov/bitrix24-php-lib/pull/2)
9+
- Fix incorrect annotation syntax from `#[\Override]` to `#[Override]`[#3](https://github.com/mesilov/bitrix24-php-lib/pull/3)
10+
- Rename package and namespaces to `bitrix24-php-lib`[#4](https://github.com/mesilov/bitrix24-php-lib/pull/4)
11+
- Add docker structure — [#13](https://github.com/mesilov/bitrix24-php-lib/pull/13)
12+
- Add application install — [#43](https://github.com/mesilov/bitrix24-php-lib/pull/43)
13+
14+
---
15+
16+
### By [@KarlsonComplete](https://github.com/KarlsonComplete)
17+
- Add docker containers — [#12](https://github.com/mesilov/bitrix24-php-lib/pull/12)
18+
- Add docker structure — [#14](https://github.com/mesilov/bitrix24-php-lib/pull/14), [#15](https://github.com/mesilov/bitrix24-php-lib/pull/15), [#16](https://github.com/mesilov/bitrix24-php-lib/pull/16), [#17](https://github.com/mesilov/bitrix24-php-lib/pull/17), [#19](https://github.com/mesilov/bitrix24-php-lib/pull/19), [#27](https://github.com/mesilov/bitrix24-php-lib/pull/27), [#29](https://github.com/mesilov/bitrix24-php-lib/pull/29), [#32](https://github.com/mesilov/bitrix24-php-lib/pull/32), [#34](https://github.com/mesilov/bitrix24-php-lib/pull/34), [#36](https://github.com/mesilov/bitrix24-php-lib/pull/36), [#37](https://github.com/mesilov/bitrix24-php-lib/pull/37), [#38](https://github.com/mesilov/bitrix24-php-lib/pull/38)
19+
- Added mapping, fixing functional tests — [#18](https://github.com/mesilov/bitrix24-php-lib/pull/18)
20+
- Removed attributes in the account — [#20](https://github.com/mesilov/bitrix24-php-lib/pull/20)
21+
- Fixed some errors in functional tests — [#21](https://github.com/mesilov/bitrix24-php-lib/pull/21)
22+
- Added fetcher test and removed more comments — [#22](https://github.com/mesilov/bitrix24-php-lib/pull/22)
23+
- Fixes — [#23](https://github.com/mesilov/bitrix24-php-lib/pull/23)
24+
- Fixes for scope — [#24](https://github.com/mesilov/bitrix24-php-lib/pull/24)
25+
- Update fetcher and flusher — [#25](https://github.com/mesilov/bitrix24-php-lib/pull/25)
26+
- Add application install — [#40](https://github.com/mesilov/bitrix24-php-lib/pull/40)

CLAUDE.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Claude Code Knowledge Base - bitrix24-php-lib
2+
3+
## Project Overview
4+
PHP library for rapid Bitrix24 application development using PostgreSQL and Doctrine ORM.
5+
6+
## Architecture
7+
- **Domain-Driven Design** with bounded contexts
8+
- **CQRS** pattern (Command/Handler)
9+
- **Event-driven** architecture
10+
- **Clean Architecture** principles
11+
12+
## Tech Stack
13+
- **PHP 8.3** (strict requirements)
14+
- **Doctrine ORM 3** for database operations
15+
- **Symfony** components (Console, Cache, Event Dispatcher, Serializer, UID, etc.)
16+
- **PostgreSQL** as primary database
17+
- **Docker** for development environment
18+
19+
## Development Tools
20+
- **PHPStan** (level 5) - static analysis
21+
- **PHPUnit** - testing framework
22+
- **Rector** - code refactoring
23+
- **PHP-CS-Fixer** - code formatting
24+
- **Composer** - dependency management
25+
26+
## Key Commands
27+
```bash
28+
# Development environment
29+
make init # Initialize project
30+
make up # Start containers
31+
make down # Stop containers
32+
33+
# Code quality
34+
make lint-phpstan # Run PHPStan analysis
35+
make lint-cs-fixer # Check code style
36+
make lint-cs-fixer-fix # Fix code style
37+
make lint-rector # Check for refactoring opportunities
38+
make lint-rector-fix # Apply Rector refactoring
39+
40+
# Testing
41+
make test-run-unit # Run unit tests
42+
make test-run-functional # Run functional tests (requires DB)
43+
44+
# Database operations
45+
make schema-drop # Drop database schema
46+
make schema-create # Create database schema
47+
```
48+
49+
## Project Structure
50+
```
51+
src/
52+
├── Bitrix24Accounts/ # Account management bounded context
53+
│ ├── Entity/ # Domain entities
54+
│ ├── Infrastructure/ # Infrastructure layer (repositories)
55+
│ ├── UseCase/ # CQRS commands/handlers
56+
│ └── ValueObjects/ # Value objects
57+
├── ApplicationInstallations/ # Installation management bounded context
58+
│ ├── Entity/
59+
│ ├── Infrastructure/
60+
│ └── UseCase/
61+
├── Services/ # Shared services
62+
└── Resources/config/ # Configuration files
63+
```
64+
65+
## Bounded Contexts
66+
1. **Bitrix24Accounts** - Bitrix24 account and access token management
67+
2. **ApplicationInstallations** - Application installation tracking
68+
3. **ContactPersons** - Contact person management
69+
4. **Bitrix24Partners** - Partner management
70+
71+
## Code Standards
72+
- Strict typing (`declare(strict_types=1)`)
73+
- Readonly classes for commands
74+
- Comprehensive validation in command constructors
75+
- Interface-based dependencies
76+
- PSR-4 autoloading
77+
- Namespace: `Bitrix24\Lib\`
78+
79+
## Testing Strategy
80+
- **Unit tests** for business logic
81+
- **Functional tests** with real database
82+
- Test builders for entity creation
83+
- Separate test database configuration
84+
85+
## Database Configuration
86+
- Uses Doctrine ORM with XML mapping
87+
- Entity mappings in `config/xml/`
88+
- Migration support via Doctrine Migrations
89+
90+
## Development Workflow
91+
1. Always run linters before committing
92+
2. Ensure all tests pass
93+
3. Follow DDD principles
94+
4. Use CQRS for write operations
95+
5. Validate all inputs in command constructors
96+
97+
## Git Workflow
98+
- Main branch: `main`
99+
- Feature branches: `feature/issue-number-description`
100+
- Current branch: `feature/46-fix-errors`
101+
102+
## Docker Setup
103+
- PHP CLI container for development
104+
- PostgreSQL database
105+
- All commands run through Docker Compose
106+
107+
## Dependencies
108+
- Core: `bitrix24/b24phpsdk` (dev-dev branch)
109+
- Framework: Symfony components
110+
- Database: Doctrine ORM 3
111+
- Utilities: Carbon, Money, LibPhoneNumber, IP handling
112+
113+
## Environment Variables
114+
Located in `.env` and `.env.local` files for database configuration.
115+
116+
### Default Configuration for Functional Tests
117+
The `.env` file contains default values that work out-of-the-box with Docker Compose:
118+
- `DATABASE_HOST=database` (Docker service name)
119+
- `DATABASE_USER=b24phpLibTest`
120+
- `DATABASE_PASSWORD=b24phpLibTest`
121+
- `DATABASE_NAME=b24phpLibTest`
122+
- `POSTGRES_VERSION=16`
123+
124+
These defaults allow running functional tests immediately after `make up` without additional configuration.

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ down-clear:
6666

6767
restart: down up
6868

69-
# работа с контейнерами
69+
# container operations
7070
php-cli-bash:
7171
docker-compose run --rm php-cli sh $(filter-out $@,$(MAKECMDGOALS))
7272

73-
# работа с composer
73+
# composer operations
7474
composer-install:
7575
@echo "install dependencies…"
7676
docker-compose run --rm php-cli composer install
@@ -81,8 +81,8 @@ composer-update:
8181

8282
composer-dumpautoload:
8383
docker-compose run --rm php-cli composer dumpautoload
84-
# вызов composer с любыми параметрами
85-
# Примеры:
84+
# composer call with any parameters
85+
# Examples:
8686
# make composer install
8787
# make composer "install --no-dev"
8888
composer:
@@ -114,7 +114,7 @@ test-run-functional: debug-print-env
114114
docker-compose run --rm php-cli php bin/doctrine orm:schema-tool:update --dump-sql
115115
docker-compose run --rm php-cli php vendor/bin/phpunit --testsuite=functional_tests --display-warnings --testdox
116116

117-
# Запустить один функциональный тест с дебагером
117+
# Run one functional test with debugger
118118
run-one-functional-test: debug-print-env
119119
docker-compose run --rm php-cli php -dxdebug.start_with_request=yes vendor/bin/phpunit --filter 'testChangeDomainUrlWithHappyPath' tests/Functional/Bitrix24Accounts/UseCase/ChangeDomainUrl/HandlerTest.php
120120

README.md

Lines changed: 60 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,50 @@
22

33
PHP lib for Bitrix24 application development
44

5-
## Область применения
5+
## Application Domain
66

7-
Библиотека предназначена для быстрой разработки приложений для Битркис24. Предоставляет слой хранения данных в СУБД
8-
[PostgreSQL](https://www.postgresql.org/), использует [Doctrine ORM](https://www.doctrine-project.org/).
7+
The library is designed for rapid development of Bitrix24 applications. Provides data storage layer in
8+
[PostgreSQL](https://www.postgresql.org/) database using [Doctrine ORM](https://www.doctrine-project.org/).
99

10-
Реализует [контракты](https://github.com/mesilov/bitrix24-php-sdk/tree/master/src/Application/Contracts) из
10+
Implements [contracts](https://github.com/mesilov/bitrix24-php-sdk/tree/master/src/Application/Contracts) from
1111
bitrix24-php-sdk.
1212

13-
## Поддерживаемые контракты
13+
## Supported Contracts
1414

1515
### Bitrix24Accounts
1616

17-
Отвечает за
18-
хранение [аккаунтов Битрикс24](https://github.com/mesilov/bitrix24-php-sdk/tree/master/src/Application/Contracts/Bitrix24Accounts)
19-
с токенами доступа к порталу.
17+
Responsible for
18+
storing [Bitrix24 accounts](https://github.com/mesilov/bitrix24-php-sdk/tree/master/src/Application/Contracts/Bitrix24Accounts)
19+
with portal access tokens.
2020

2121
### ApplicationInstallations
2222

23-
Отвечает за
24-
хранение [фактов установок](https://github.com/mesilov/bitrix24-php-sdk/tree/master/src/Application/Contracts/ApplicationInstallations)
25-
приложения на конкретный портал Битркис24
23+
Responsible for
24+
storing [installation facts](https://github.com/mesilov/bitrix24-php-sdk/tree/master/src/Application/Contracts/ApplicationInstallations)
25+
of applications on specific Bitrix24 portals
2626

2727
### ContactPersons
2828

29-
Отвечает за
30-
хранение [контактных лиц](https://github.com/mesilov/bitrix24-php-sdk/tree/master/src/Application/Contracts/ContactPersons),
31-
которые произвели установку приложения
29+
Responsible for
30+
storing [contact persons](https://github.com/mesilov/bitrix24-php-sdk/tree/master/src/Application/Contracts/ContactPersons)
31+
who performed application installation
3232

3333
### Bitrix24Partners
3434

35-
Отвечает за
36-
хранение [партнёра](https://github.com/mesilov/bitrix24-php-sdk/tree/master/src/Application/Contracts/Bitrix24Partners) Битрикс24, который произвёл установку или обслуживает портал
35+
Responsible for
36+
storing [Bitrix24 partners](https://github.com/mesilov/bitrix24-php-sdk/tree/master/src/Application/Contracts/Bitrix24Partners) who performed installation or service the portal
3737

38-
## Архитектура
38+
## Architecture
3939

40-
### Слои и уровни абстракции
40+
### Layers and Abstraction Levels
4141
```
42-
bitrix24-app-laravel-skeleton – шаблон приложения на Laravel
43-
bitrix24-app-symfony-skeleton – шаблон приложения на Symfony
44-
bitrix24-php-lib – работа с сущностями приложения и их хранение в СУБД
45-
bitrix24-php-sdk – транспортный слой + события транспорта (протух токен, переименовали портал)
42+
bitrix24-app-laravel-skeleton – Laravel application template
43+
bitrix24-app-symfony-skeleton – Symfony application template
44+
bitrix24-php-lib – application entities work and their storage in database
45+
bitrix24-php-sdk – transport layer + transport events (expired token, portal renamed)
4646
```
4747

48-
### Структура папок bounded context
48+
### Bounded Context Folder Structure
4949
```
5050
src/
5151
Bitrix24Accounts
@@ -66,13 +66,42 @@ src/
6666
```
6767

6868

69-
## Инфраструктура
70-
- библиотека делается cloud-agnostic
69+
## Quick Start
7170

71+
### Prerequisites
72+
- Docker and Docker Compose
73+
- Make
7274

73-
## Правила разработки
74-
1. Используем линтеры
75-
2. Библиотека покрыта тестами
76-
3. Вся работа строится через issues
77-
4. Процессы разработки - remote first
78-
5. Думаем и обсуждаем — потом пишем
75+
### Running Tests
76+
```bash
77+
# Initialize and start services
78+
make up
79+
80+
# Run functional tests (uses default database configuration)
81+
make test-run-functional
82+
83+
# Run linters
84+
make lint-phpstan
85+
make lint-cs-fixer
86+
make lint-rector
87+
```
88+
89+
### Database Configuration
90+
Default database credentials are pre-configured in `.env`:
91+
- Host: `database` (Docker service)
92+
- Database: `b24phpLibTest`
93+
- User: `b24phpLibTest`
94+
- Password: `b24phpLibTest`
95+
96+
No additional configuration needed for running tests.
97+
98+
## Infrastructure
99+
- library is made cloud-agnostic
100+
101+
102+
## Development Rules
103+
1. We use linters
104+
2. Library is covered with tests
105+
3. All work is organized through issues
106+
4. Development processes are remote first
107+
5. Think and discuss — then write

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
}
3535
},
3636
"require": {
37-
"php": "8.3.*",
37+
"php": "^8.3",
3838
"ext-json": "*",
3939
"ext-curl": "*",
4040
"ext-bcmath": "*",

docker/php-cli/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:8.3-cli-alpine
1+
FROM php:8.4-cli-alpine
22

33
RUN apk add unzip libpq-dev git icu-dev autoconf build-base linux-headers \
44
&& docker-php-ext-install bcmath pdo pdo_pgsql intl \

0 commit comments

Comments
 (0)