Skip to content

Commit 7793d8c

Browse files
authored
Merge pull request #43 from malakaton/solution-tiered-pricing-php
Added solution in php for TDD exercise tiered pricing
2 parents f4e21c9 + eff3117 commit 7793d8c

Some content is hidden

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

58 files changed

+8339
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.env.local
2+
/.env.local.php
3+
/.env.*.local
4+
.idea
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
### Requirements
2+
- [Docker](https://www.docker.com/)
3+
4+
### Start working
5+
Install and run the application.
6+
```sh
7+
docker/up
8+
```
9+
## Running tests
10+
With this command you will execute all the test (Functional, Integration, Unit and e2e). You don't need to execute something more.
11+
```sh
12+
docker/test
13+
```
14+
![Alt Text](https://64.media.tumblr.com/723987e60ebfffeb744f84fa92e52245/tumblr_neglojBBbo1sx56xso1_400.gif)
15+
<br>
16+
"We are amidst strange beings, in a strange land."
17+
<br><br>
18+
Solaire De Astora
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: '3.7'
2+
3+
services:
4+
5+
# APP SERVICES
6+
php-fpm:
7+
build:
8+
target: development
9+
context: .
10+
dockerfile: ./docker/php-fpm/Dockerfile
11+
volumes:
12+
- ./src/:/opt/app/
13+
- "./docker/php-fpm/conf/php-fpm.conf:/etc/php-fpm.conf"
14+
- "./docker/php-fpm/conf/php.ini:/usr/local/etc/php/conf.d/100-php.ini"
15+
16+
nginx:
17+
build: docker/nginx
18+
volumes:
19+
- "./docker/nginx/conf/project.conf:/etc/nginx/conf.d/00-project.conf"
20+
depends_on:
21+
- php-fpm
22+
ports:
23+
- 80:80
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM nginx:1.16
2+
3+
COPY conf/project.conf /etc/nginx/conf.d/00-project.conf
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
upstream php_upstream { # define our php upstream
2+
server php-fpm:9000;
3+
}
4+
5+
server {
6+
listen 80;
7+
server_name oursuperawesometwittershoutapi.com project.tld;
8+
9+
root /opt/app/public;
10+
index index.php;
11+
12+
location / {
13+
try_files $uri $uri/ /index.php$is_args$args;
14+
}
15+
16+
error_page 404 /index.php;
17+
18+
location ~ ^/(index)\.php(/|$) {
19+
fastcgi_pass php-fpm:9000;
20+
fastcgi_index index.php;
21+
22+
include fastcgi_params;
23+
24+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
25+
fastcgi_param PATH_INFO $fastcgi_path_info;
26+
}
27+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
FROM php:8.1.5-fpm-alpine as production
2+
3+
# Install needed modules to run the application
4+
RUN apk update \
5+
&& apk --quiet add \
6+
libzip-dev
7+
8+
# Add php extension to work with zip files
9+
RUN docker-php-ext-install -j$(nproc) \
10+
zip
11+
12+
RUN apk --no-cache add pcre-dev ${PHPIZE_DEPS} \
13+
&& pecl install -o -f redis \
14+
&& rm -rf /tmp/pear \
15+
&& docker-php-ext-enable redis \
16+
&& apk del pcre-dev ${PHPIZE_DEPS}
17+
18+
# Install OPCACHE extension
19+
RUN docker-php-ext-install opcache
20+
21+
WORKDIR /opt/app
22+
23+
# Install XDEBUG extension
24+
RUN apk add --no-cache $PHPIZE_DEPS \
25+
&& pecl install xdebug-3.1.4 \
26+
&& docker-php-ext-enable xdebug
27+
28+
29+
# Install Composer
30+
RUN curl -sS https://getcomposer.org/installer | php -- --version=2.3.5 --install-dir=/usr/local/bin --filename=composer
31+
32+
# Add prestissimo for parallel composer downloads
33+
#RUN composer global require "hirak/prestissimo"
34+
35+
# Copy source code into container
36+
COPY ./src/ .
37+
38+
# Install production dependencies
39+
RUN composer install
40+
41+
FROM production as development
42+
43+
# Install with dev dependencies
44+
CMD sh -c "composer install && docker-php-entrypoint php-fpm"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[global]
2+
3+
error_log = /proc/stderr
4+
daemonize = no
5+
6+
[www]
7+
8+
; if we send this to /proc/self/fd/1, it never appears
9+
access.log = /proc/stdout
10+
11+
; this does the trick for changing the user
12+
user = project
13+
group = project
14+
15+
listen = [::]:9000
16+
17+
pm = dynamic
18+
pm.max_children = 5
19+
pm.start_servers = 2
20+
pm.min_spare_servers = 1
21+
pm.max_spare_servers = 3
22+
23+
clear_env = no
24+
25+
; Ensure worker stdout and stderr are sent to the main error log.
26+
catch_workers_output = yes
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
display_errors = On
2+
display_startup_errors = On
3+
error_reporting = E_ALL
4+
5+
max_execution_time = 60
6+
max_input_time = 60
7+
memory_limit = 256M
8+
9+
post_max_size = 32M
10+
upload_max_filesize = 32M
11+
12+
realpath_cache_size = 4096K
13+
realpath_cache_ttl = 600
14+
15+
date.timezone = "Europe/Paris"
16+
17+
opcache.max_accelerated_files = 20000
18+
opcache.memory_consumption = 256
19+
20+
xdebug.mode=develop,debug,coverage
21+
xdebug.start_with_request=yes
22+
# Default log_level is 7
23+
xdebug.log_level=0
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
docker-compose run php-fpm vendor/bin/phpunit --testsuite='Unit' --order-by=random
4+
#docker-compose run php-fpm vendor/bin/phpunit --testsuite='Integration' --order-by=random
5+
docker-compose run php-fpm vendor/bin/phpunit --testsuite='e2e' --order-by=random
6+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
docker-compose up --build -d
4+

0 commit comments

Comments
 (0)