Skip to content

Commit 9c43d85

Browse files
authored
Merge pull request #64 from phenixphp/release/0.6.0
Release v0.6.0
2 parents 066d5bd + 0b231d5 commit 9c43d85

File tree

223 files changed

+9978
-292
lines changed

Some content is hidden

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

223 files changed

+9978
-292
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
15+
indent_size = 2

.github/copilot-instructions.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Phenix Framework AI Instructions
2+
3+
Phenix is an async-first PHP web framework built on Amphp v3 for high-performance applications. This guide helps AI agents understand the framework's unique patterns and architecture. **Phenix** is an asynchronous PHP web framework built on the [AmPHP](https://amphp.org/) ecosystem. It serves as the core framework for building scalable, async-first API applications. Official documentation can be found at [Phenix Documentation](https://phenix.omarbarbosa.com/).
4+
5+
## Core Architecture
6+
7+
### Async-First Design
8+
- Framework runs in CLI SAPI with its own HTTP server using `SocketHttpServer`
9+
- All I/O operations are non-blocking using Amphp primitives
10+
- Use `App::make()` for dependency resolution throughout the codebase
11+
- Service providers register dependencies in `App::setup()` method
12+
13+
### Application Bootstrap
14+
```php
15+
// Standard app creation pattern
16+
$app = AppBuilder::build($path, $env);
17+
$app->run(); // Starts HTTP server and handles signals
18+
```
19+
20+
### Dependency Container Pattern
21+
- Uses League Container with service providers for registration
22+
- Access via `App::make(ClassName::class)` static method
23+
- Register services: `$app->register(Key::class, $concrete)`
24+
- Facades provide static access: `Config::get('key')`, `Route::get('/path')`
25+
26+
## Key Components
27+
28+
### Routing System (`src/Routing/`)
29+
- Fluent route builder: `Route::get('/users', $handler)->middleware($middleware)`
30+
- Groups support: `Route::group(fn() => Route::get('/admin', $handler))`
31+
- Automatic dependency injection in route handlers
32+
- Middleware stacking via `stackMiddleware()`
33+
34+
### Queue System (`src/Queue/`) - Current Development Focus
35+
- Abstract `QueuableTask` base class for background jobs
36+
- Multiple drivers: `RedisQueue`, `DatabaseQueue`, `ParallelQueue`
37+
- Tasks use `ShouldQueue` interface and `enqueue()` static method
38+
- State management with `TaskState` for tracking job progress
39+
40+
### Database & Query Builder (`src/Database/`)
41+
- Async database operations using Amphp MySQL/PostgreSQL drivers
42+
- Fluent query builder with method chaining
43+
- Connection factory pattern for multiple database connections
44+
- Migration system with console commands
45+
46+
### Console Commands (`src/Console/`)
47+
- Symfony Console-based with `Phenix` application class
48+
- Maker commands extend `Maker` base class
49+
- Commands registered via service providers in `pushCommands()`
50+
- Stubs located in `src/stubs/` directory
51+
52+
## Development Patterns
53+
54+
### Service Provider Pattern
55+
```php
56+
class ExampleServiceProvider extends ServiceProvider
57+
{
58+
public function register(): void {
59+
// Register bindings in container
60+
}
61+
62+
public function provides(string $id): bool {
63+
// Declare what this provider provides
64+
}
65+
}
66+
```
67+
68+
### Testing with PestPHP
69+
- Unit tests: `tests/Unit/` with simple `it('description', fn() => expect()->toBe())`
70+
- Feature tests: `tests/Feature/` for HTTP integration
71+
- Use `Tests\TestCase` base class for both unit and feature tests
72+
- Run tests: `vendor/bin/pest`
73+
74+
### Command Creation
75+
- Extend `Maker` class for generators
76+
- Define `stub()`, `outputDirectory()`, `commonName()` methods
77+
- Use `InputArgument` and `InputOption` for CLI parameters
78+
- Stubs use Mustache-style templating
79+
80+
### Facades Pattern
81+
- Extend `Runtime\Facade` and implement `getKeyName()`
82+
- Provide `@method` docblocks for IDE support
83+
- Static calls proxy to container-resolved instances
84+
85+
## File Organization
86+
87+
- **Core**: `src/App.php` (main application), `src/AppBuilder.php` (factory)
88+
- **HTTP**: `src/Http/` (requests, responses, middleware)
89+
- **Database**: `src/Database/` (query builder, migrations, models)
90+
- **Queue**: `src/Queue/` (async job processing system)
91+
- **Console**: `src/Console/Commands/` (CLI commands)
92+
- **Config**: Framework uses dotenv with `src/Runtime/Environment`
93+
- **Tests**: PestPHP in `tests/` with `Unit/` and `Feature/` directories
94+
95+
## Key Conventions
96+
97+
- All classes use strict types: `declare(strict_types=1);`
98+
- PSR-12 code style with type hints for all methods
99+
- Async operations return Amphp `Future` objects when applicable
100+
- Service providers define dependencies in `provides()` method
101+
- Queue tasks extend `QueuableTask` and implement `handle()` method
102+
- Database models extend base model with async query methods
103+
- Middleware implements Amphp HTTP middleware interface
104+
105+
## Integration Points
106+
107+
- **AmphpPHP**: Core async runtime and HTTP server
108+
- **League Container**: Dependency injection container
109+
- **Symfony Console**: CLI command framework
110+
- **PestPHP**: Testing framework
111+
- **Monolog**: Logging with async handlers
112+
- **Redis/MySQL/PostgreSQL**: Async database drivers
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
applyTo: '**'
3+
---
4+
Coding standards, domain knowledge, and preferences that AI should follow.
5+
6+
- Use clear and descriptive variable names.
7+
- Follow the PSR-12 coding style guide.
8+
- Write unit tests for all new features and bug fixes.
9+
- Keep functions and methods small and focused on a single task.
10+
- Use type hints and return types for all functions and methods.
11+
- Avoid using global variables.
12+
- Use dependency injection instead of singletons.
13+
- Write code that is easy to read and understand.
14+
- Keep the codebase organized and modular.
15+
16+
## Context
17+
18+
- This project is a framework to build API applications.
19+
- The primary language used is PHP.
20+
- This framework is based on Amphp version 3, a high-performance asynchronous PHP framework.
21+
- The application uses a MySQL, PostgreSQL, and SQLite database for data storage.
22+
- The application uses Redis for caching.
23+
- The application uses PestPHP for unit testing.
24+
- The application uses Composer for dependency management.
25+
26+
## Paths
27+
28+
- Application code is located in the `src` directory.
29+
- Tests are located in the `tests` directory.
30+
31+
## Framework components
32+
33+
- Crypto: `src/Crypto`
34+
- Database: `src/Database`
35+
- Query Builder: `src/Database/QueryBuilder`
36+
- Filesystem: `src/Filesystem`
37+
- Logging: `src/Logging`
38+
- Mail: `src/Mail`
39+
- Queue: `src/Queue`
40+
- Routing: `src/Routing`
41+
- Session: `src/Session`
42+
- Tasks: `src/Tasks`
43+
- Validation: `src/Validation`
44+
- Views: `src/Views`
45+
46+
## Current feature under development
47+
48+
- The current feature under development is the `src/Queue` component, which provides a unified API for managing background tasks processing.
49+
- The `src/Queue` uses queuable task `src/Queue/QueuableTask` for defining tasks that can be processed in the background.
50+
- The `src/Queue` component supports multiple queue drivers, including redis, database, and parallel.

.github/workflows/run-tests.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
with:
2222
php-version: 8.2
2323
extensions: json, mbstring, pcntl, intl, fileinfo
24-
coverage: xdebug
24+
coverage: pcov
2525

2626
- name: Setup problem matchers
2727
run: |
@@ -36,10 +36,6 @@ jobs:
3636
run: |
3737
vendor/bin/php-cs-fixer fix --dry-run --diff --ansi
3838
39-
- name: Check quality code with PHPInsights
40-
run: |
41-
vendor/bin/phpinsights -n --ansi --format=github-action
42-
4339
- name: Analyze code statically with PHPStan
4440
run: |
4541
vendor/bin/phpstan
@@ -55,7 +51,7 @@ jobs:
5551
sed -i "s|$GITHUB_WORKSPACE|/github/workspace|g" build/report.junit.xml
5652
5753
- name: Run SonarQube analysis
58-
uses: sonarsource/sonarcloud-github-action@master
54+
uses: sonarsource/sonarqube-scan-action@master
5955
env:
6056
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6157
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ Thumbs.db
1111
.phpunit.result.cache
1212
.php-cs-fixer.cache
1313
build
14-
tests/fixtures/application/storage/framework/logs/*.log
14+
tests/fixtures/application/storage/framework/logs/*.log
15+
tests/fixtures/application/storage/framework/views/*.php
16+
.env

.php-cs-fixer.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use PhpCsFixer\Config;
44
use PhpCsFixer\Finder;
5+
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
56

67
$rules = [
78
'@PSR12' => true,
@@ -40,8 +41,9 @@
4041
->ignoreDotFiles(true)
4142
->ignoreVCS(true);
4243

43-
return (new Config)
44+
return (new Config())
4445
->setFinder($finder)
4546
->setRules($rules)
4647
->setRiskyAllowed(true)
47-
->setUsingCache(true);
48+
->setUsingCache(true)
49+
->setParallelConfig(ParallelConfigFactory::detect());

CHANGELOG.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,40 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
# Release Notes for 0.6.x
11+
12+
## [v0.6.0 (2025-08-22)](https://github.com/phenixphp/framework/compare/0.5.2...0.6.0)
13+
14+
### Added
15+
16+
- Queue system. ([#63](https://github.com/phenixphp/framework/pull/63))
17+
- Cryptographic module for encryption and decryption operations. ([#60](https://github.com/phenixphp/framework/pull/60))
18+
- Sending emails. ([#58](https://github.com/phenixphp/framework/pull/58))
19+
- Template engine. ([#54](https://github.com/phenixphp/framework/pull/54))
20+
- Key generation command. ([#52](https://github.com/phenixphp/framework/pull/52))
21+
22+
### Changed
23+
24+
- Host and port as optionals argument in cli for start server by [@FSHLL](https://github.com/FSHLL). ([#53](https://github.com/phenixphp/framework/pull/53))
25+
1026
# Release Notes for 0.5.x
1127

1228
## [v0.5.2 (2025-01-03)](https://github.com/phenixphp/framework/compare/0.5.1...0.5.2)
1329

1430
### Added
31+
1532
- Session management with support for local in memory and redis drivers. ([#49](https://github.com/phenixphp/framework/pull/49))
1633

1734
## [v0.5.1 (2024-12-24)](https://github.com/phenixphp/framework/compare/0.5.0...0.5.1)
1835

1936
### Added
37+
2038
- Options to make models with controller and migrations. ([#46](https://github.com/phenixphp/framework/pull/46))
2139

2240
## [v0.5.0 (2024-12-20)](https://github.com/phenixphp/framework/compare/0.4.0...0.5.0)
2341

2442
### Added
43+
2544
- Log facade. ([#42](https://github.com/phenixphp/framework/pull/42))
2645
- Database model API. ([#41](https://github.com/phenixphp/framework/pull/41))
2746
- Commands to make models, queries and model collections. ([#40](https://github.com/phenixphp/framework/pull/40))
@@ -32,6 +51,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3251
## [v0.4.0 (2024-09-27)](https://github.com/phenixphp/framework/compare/0.3.8...0.4.0)
3352

3453
### Added
54+
3555
- Database validations (unique, exists). ([#36](https://github.com/phenixphp/framework/pull/36))
3656
- File validation. ([#35](https://github.com/phenixphp/framework/pull/35))
3757
- Move validation layer to framework. ([#34](https://github.com/phenixphp/framework/pull/34))
@@ -45,80 +65,94 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4565
## [v0.3.8 (2023-10-10)](https://github.com/phenixphp/framework/compare/0.3.7...0.3.8)
4666

4767
### Fixed
68+
4869
- Load router on booting. ([#27](https://github.com/phenixphp/framework/pull/27))
4970

5071
## [v0.3.7 (2023-10-10)](https://github.com/phenixphp/framework/compare/0.3.6...0.3.7)
5172

5273
### Added
74+
5375
- Add FakerPHP to Seed class. ([#24](https://github.com/phenixphp/framework/pull/24))
5476
- Command to make service providers. ([#23](https://github.com/phenixphp/framework/pull/23))
5577
- `pcntl` as required extension. ([#22](https://github.com/phenixphp/framework/pull/22))
5678

5779
## [v0.3.6 (2023-10-07)](https://github.com/phenixphp/framework/compare/0.3.5...0.3.6)
5880

5981
### Added
82+
6083
- HTTP utility to handle request attributes. ([#19](https://github.com/phenixphp/framework/pull/19))
6184

6285
## [v0.3.5 (2023-10-06)](https://github.com/phenixphp/framework/compare/0.3.4...0.3.5)
6386

6487
### Fixed
88+
6589
- Update README. ([#16](https://github.com/phenixphp/framework/pull/16))
6690

6791
## [v0.3.4 (2023-10-06)](https://github.com/phenixphp/framework/compare/0.3.3...0.3.4)
6892

6993
### Fixed
94+
7095
- JSON header in responses. ([#13](https://github.com/phenixphp/framework/pull/13))
7196

7297
## [v0.3.3 (2023-10-06)](https://github.com/phenixphp/framework/compare/0.3.2...0.3.3)
7398

7499
### Fixed
100+
75101
- Get stubs content from framework path. ([#10](https://github.com/phenixphp/framework/pull/10))
76102

77103
## [v0.3.2 (2023-10-05)](https://github.com/phenixphp/framework/compare/0.3.1...0.3.2)
78104

79105
### Changed
106+
80107
- Add method to get environment file in test case. ([#7](https://github.com/phenixphp/framework/pull/7))
81108

82109
## [v0.3.1 (2023-10-05)](https://github.com/phenixphp/framework/compare/0.3.0...0.3.1)
83110

84111
### Changed
112+
85113
- Test utilities moved to framework. ([#4](https://github.com/phenixphp/framework/pull/4))
86114

87115
## v0.3.0 (2023-10-05)
88116

89117
### Changed
118+
90119
- The query builder `selectAllColumns` method now is optional. ([#1](https://github.com/phenixphp/framework/pull/1))
91120

92121
# Release Notes for 0.2.x
93122

94123
## [v0.2.1 (2023-09-30)](https://github.com/phenixphp/phenix/compare/0.2.0...0.2.1)
95124

96125
### Fixed
126+
97127
- Ensure dabatase directory exists before create migration. ([49](https://github.com/phenixphp/phenix/pull/49))
98128

99129
## [v0.2.0 (2023-09-29)](https://github.com/phenixphp/phenix/compare/0.1.0...0.2.0)
100130

101131
### Added
132+
102133
- Add `paginate` method to the query builder. ([42](https://github.com/phenixphp/phenix/pull/42))
103134
- Add `count` method to the query builder. ([42](https://github.com/phenixphp/phenix/pull/42))
104135
- Add `insert` method to the query builder. ([43](https://github.com/phenixphp/phenix/pull/43))
105136
- Add `exists` and `doesntExists` methods to the query builder. ([#44](https://github.com/phenixphp/phenix/pull/44))
106137
- Add `delete` method to the query builder. ([#45](https://github.com/phenixphp/phenix/pull/45))
107138

108139
### Changed
140+
109141
- Load routes before server running. ([#41](https://github.com/phenixphp/phenix/pull/41))
110142
- Load custom environment files. ([#40](https://github.com/phenixphp/phenix/pull/40))
111143
- Improve service provider structure. ([#38](https://github.com/phenixphp/phenix/pull/38))
112144
- Improve class API to `\Phenix\Database\QueryGenerator`, now it has final methods. ([#44](https://github.com/phenixphp/phenix/pull/44))
113145

114146
### Fixed
147+
115148
- Apply provides in database service provider. ([#46](https://github.com/phenixphp/phenix/pull/46))
116149

117150
# Release Notes for 0.1.x
118151

119152
## [v0.1.0 (2023-09-15)](https://github.com/phenixphp/phenix/compare/0.0.1-alpha.1...0.1.0)
120153

121154
### Added
155+
122156
- Migrations and seeder support. ([#35](https://github.com/phenixphp/phenix/pull/35))
123157
- Basic query builder ([#33](https://github.com/phenixphp/phenix/pull/33))
124158
- Routes with support for groups ([#28](https://github.com/phenixphp/phenix/pull/28))

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,8 @@ If you discover a security vulnerability within Phenix, please send an e-mail to
1919
## License
2020

2121
The Phenix framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
22+
23+
## Credits
24+
25+
- [Amphp team](https://amphp.org/)
26+
- [Laravel team](https://laravel.com/)

0 commit comments

Comments
 (0)