Skip to content

Commit 57a49a6

Browse files
authored
Merge pull request #5 from Larium/feature/php-support
Support more php versions
2 parents 80af98a + 42d585d commit 57a49a6

File tree

8 files changed

+226
-20
lines changed

8 files changed

+226
-20
lines changed

.docker/php8.2-cli/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM php:8.2-cli
2+
WORKDIR "/opt/php"
3+
4+
ENV DEBIAN_FRONTEND=noninteractive
5+
6+
RUN apt-get update && \
7+
apt-get install -y zip libzip-dev && \
8+
pecl channel-update pecl.php.net && \
9+
pecl install xdebug && \
10+
docker-php-ext-install bcmath zip && \
11+
docker-php-source delete && \
12+
rm -r /tmp/* /var/cache/*
13+
14+
COPY ./.docker/php8.4-cli/php-ini-overrides.ini /usr/local/etc/php/conf.d/99-overrides.ini
15+
16+
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
17+
&& php composer-setup.php \
18+
&& php -r "unlink('composer-setup.php');" \
19+
&& chmod +x composer.phar \
20+
&& mv composer.phar /usr/local/bin/composer
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
2+
error_log = /dev/stderr
3+
log_errors = On
4+
display_startup_errors = Off
5+
date.timezone = UTC
6+
upload_max_filesize = 8M
7+
post_max_size = 8M
8+
html_errors = Off
9+
memory_limit = 512M
10+
max_execution_time = 60
11+
expose_php = Off
12+
zend_extension=xdebug.so
13+
xdebug.mode=coverage

.docker/php8.3-cli/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM php:8.3-cli
2+
WORKDIR "/opt/php"
3+
4+
ENV DEBIAN_FRONTEND=noninteractive
5+
6+
RUN apt-get update && \
7+
apt-get install -y zip libzip-dev && \
8+
pecl channel-update pecl.php.net && \
9+
pecl install xdebug && \
10+
docker-php-ext-install bcmath zip && \
11+
docker-php-source delete && \
12+
rm -r /tmp/* /var/cache/*
13+
14+
COPY ./.docker/php8.4-cli/php-ini-overrides.ini /usr/local/etc/php/conf.d/99-overrides.ini
15+
16+
RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
17+
&& php composer-setup.php \
18+
&& php -r "unlink('composer-setup.php');" \
19+
&& chmod +x composer.phar \
20+
&& mv composer.phar /usr/local/bin/composer
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
2+
error_log = /dev/stderr
3+
log_errors = On
4+
display_startup_errors = Off
5+
date.timezone = UTC
6+
upload_max_filesize = 8M
7+
post_max_size = 8M
8+
html_errors = Off
9+
memory_limit = 512M
10+
max_execution_time = 60
11+
expose_php = Off
12+
zend_extension=xdebug.so
13+
xdebug.mode=coverage

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,15 @@ composer-update:
44
docker run -v $(shell pwd):/opt/php framework-8.4 sh -c 'composer update'
55
run-tests:
66
docker run -v $(shell pwd):/opt/php framework-8.4 sh -c './vendor/bin/phpunit tests/'
7+
docker-build-8.3:
8+
docker build -f .docker/php8.4-cli/Dockerfile -t framework-8.3 .
9+
composer-update-8.3:
10+
docker run -v $(shell pwd):/opt/php framework-8.3 sh -c 'composer update'
11+
run-tests-8.3:
12+
docker run -v $(shell pwd):/opt/php framework-8.3 sh -c './vendor/bin/phpunit tests/'
13+
docker-build-8.2:
14+
docker build -f .docker/php8.4-cli/Dockerfile -t framework-8.2 .
15+
composer-update-8.2:
16+
docker run -v $(shell pwd):/opt/php framework-8.2 sh -c 'composer update'
17+
run-tests-8.2:
18+
docker run -v $(shell pwd):/opt/php framework-8.2 sh -c './vendor/bin/phpunit tests/'

README.md

Lines changed: 119 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,88 @@
1-
# PSR-15 framework
1+
# PSR-15 Framework
2+
3+
A lightweight PSR-15 compliant framework for building HTTP applications with middleware support and dependency injection.
4+
5+
## Requirements
6+
7+
- PHP 8.2, 8.3, or 8.4
8+
- Composer
9+
- Docker (for development environment)
10+
11+
## Installation
12+
13+
### As a Composer Package (Recommended)
14+
15+
Install the framework as a dependency in your project:
16+
17+
```bash
18+
composer require larium/framework
19+
```
20+
21+
### Development Setup
22+
23+
If you want to contribute to the framework or run it locally:
24+
25+
1. **Clone the repository:**
26+
```bash
27+
git clone git@github.com:Larium/framework.git
28+
cd framework
29+
```
30+
31+
2. **Install dependencies:**
32+
```bash
33+
composer install
34+
```
35+
36+
## Development Environment
37+
38+
This project uses Docker for consistent development environments across different PHP versions.
39+
40+
### Using Make Commands
41+
42+
The project includes several make commands for common development tasks:
43+
44+
#### Docker Environment Setup
45+
- `make docker-build` - Build Docker image for PHP 8.4
46+
- `make docker-build-8.3` - Build Docker image for PHP 8.3
47+
- `make docker-build-8.2` - Build Docker image for PHP 8.2
48+
49+
#### Dependency Management
50+
- `make composer-update` - Update dependencies using PHP 8.4 Docker container
51+
- `make composer-update-8.3` - Update dependencies using PHP 8.3 Docker container
52+
- `make composer-update-8.2` - Update dependencies using PHP 8.2 Docker container
53+
54+
#### Testing
55+
- `make run-tests` - Run tests using PHP 8.4 Docker container
56+
- `make run-tests-8.3` - Run tests using PHP 8.3 Docker container
57+
- `make run-tests-8.2` - Run tests using PHP 8.2 Docker container
58+
59+
### Manual Setup (without Docker)
60+
61+
If you prefer to work without Docker:
62+
63+
1. **Install PHP 8.2+** with required extensions:
64+
- bcmath
65+
- zip
66+
- xdebug (for development)
67+
68+
2. **Install Composer** if not already installed:
69+
```bash
70+
curl -sS https://getcomposer.org/installer | php
71+
sudo mv composer.phar /usr/local/bin/composer
72+
```
73+
74+
3. **Install dependencies:**
75+
```bash
76+
composer install
77+
```
78+
79+
4. **Run tests:**
80+
```bash
81+
./vendor/bin/phpunit tests/
82+
```
83+
84+
## Usage Example
285

3-
## Example
486
```php
587
<?php
688
# public/index.php
@@ -16,7 +98,7 @@ use Larium\Framework\Provider\ContainerProvider;
1698
require_once __DIR__ . '/../vendor/autoload.php';
1799

18100
(function () {
19-
/** @var ContainerProvider */
101+
/** @var ContainerProvider [implement the ContainerProvider interface] */
20102
$containerProvider
21103
$container = $containerProvider->getContainer();
22104

@@ -28,3 +110,37 @@ require_once __DIR__ . '/../vendor/autoload.php';
28110
$f->run(ServerRequestFactory::fromGlobals());
29111
})();
30112
```
113+
114+
## Project Structure
115+
116+
- `src/` - Framework source code
117+
- `tests/` - Test suite
118+
- `.docker/` - Docker configuration for different PHP versions
119+
- `build/` - Build artifacts and coverage reports
120+
- `vendor/` - Composer dependencies
121+
122+
## Testing
123+
124+
Run the test suite using one of these methods:
125+
126+
**Using Make (recommended):**
127+
```bash
128+
make run-tests
129+
```
130+
131+
**Using PHPUnit directly:**
132+
```bash
133+
./vendor/bin/phpunit tests/
134+
```
135+
136+
## Contributing
137+
138+
1. Fork the repository
139+
2. Create a feature branch
140+
3. Make your changes
141+
4. Run tests: `make run-tests`
142+
5. Submit a pull request
143+
144+
## License
145+
146+
MIT License - see LICENSE file for details.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
}
1212
],
1313
"require": {
14-
"php": ">=8.4",
14+
"php": "^8.2|^8.3|^8.4",
1515
"psr/http-message": "^1.0|^2.0",
1616
"psr/http-server-handler": "~1.0",
1717
"psr/http-server-middleware": "~1.0",

composer.lock

Lines changed: 28 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)