Compare commits
10 Commits
666f37eea2
...
48f87ce821
| Author | SHA1 | Date | |
|---|---|---|---|
| 48f87ce821 | |||
| 16a94d8d55 | |||
| b5b956b1d1 | |||
| c2d91ffaea | |||
| 276606d2eb | |||
| 137d10a515 | |||
| 3c194fe99d | |||
| a89d5e1292 | |||
| fe23dfb27a | |||
| 14c689f058 |
21
docker-compose.yml
Normal file
21
docker-compose.yml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
services:
|
||||||
|
php:
|
||||||
|
build:
|
||||||
|
context: ./docker/php
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
container_name: php-fpm
|
||||||
|
volumes:
|
||||||
|
- ./src:/var/www/html/src
|
||||||
|
- ./vendor:/var/www/html/vendor
|
||||||
|
- ./docker/php/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
image: nginx:alpine
|
||||||
|
container_name: nginx
|
||||||
|
ports:
|
||||||
|
- "8080:80"
|
||||||
|
volumes:
|
||||||
|
- ./src:/var/www/html/src
|
||||||
|
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
|
||||||
|
depends_on:
|
||||||
|
- php
|
||||||
17
docker/nginx/default.conf
Normal file
17
docker/nginx/default.conf
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name localhost;
|
||||||
|
index index.php;
|
||||||
|
|
||||||
|
root /var/www/html/src;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php?$args;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
fastcgi_pass php:9000;
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
15
docker/php/Dockerfile
Normal file
15
docker/php/Dockerfile
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# PHP-FPM runtime
|
||||||
|
FROM php:8.5-fpm-alpine
|
||||||
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
|
# Install PHP Xdebug Extention
|
||||||
|
RUN apk add --no-cache $PHPIZE_DEPS linux-headers && pecl install xdebug
|
||||||
|
|
||||||
|
# Enable PHP installed extensions
|
||||||
|
RUN docker-php-ext-enable xdebug
|
||||||
|
|
||||||
|
# Install PHP bundled extensions
|
||||||
|
# RUN docker-php-ext-install pdo_mysql
|
||||||
|
|
||||||
|
# Expose port 9000 (default for php-fpm)
|
||||||
|
EXPOSE 9000
|
||||||
8
docker/php/xdebug.ini
Normal file
8
docker/php/xdebug.ini
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
zend_extension=xdebug
|
||||||
|
|
||||||
|
[xdebug]
|
||||||
|
xdebug.mode=develop,debug
|
||||||
|
xdebug.start_with_request=yes
|
||||||
|
xdebug.discover_client_host=0
|
||||||
|
xdebug.client_host=host.docker.internal
|
||||||
|
xdebug.client_port=9003
|
||||||
35
src/index.php
Normal file
35
src/index.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require '../vendor/autoload.php';
|
||||||
|
|
||||||
|
use GuzzleHttp\Client;
|
||||||
|
use GuzzleHttp\Exception\GuzzleException;
|
||||||
|
use GuzzleHttp\Psr7\Request;
|
||||||
|
|
||||||
|
$client = new Client();
|
||||||
|
|
||||||
|
try {
|
||||||
|
$response = $client->request('GET', 'https://api.github.com/repos/guzzle/guzzle');
|
||||||
|
} catch (GuzzleException $e) {
|
||||||
|
echo $e->getMessage();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo $response->getStatusCode() . PHP_EOL;
|
||||||
|
echo $response->getHeaderLine('content-type') . PHP_EOL;
|
||||||
|
echo $response->getBody() . PHP_EOL;
|
||||||
|
|
||||||
|
// asynchronous
|
||||||
|
$request = new Request('GET', 'http://httpbin.org');
|
||||||
|
|
||||||
|
$promise = $client
|
||||||
|
->sendAsync($request)
|
||||||
|
->then(function ($response) {
|
||||||
|
echo 'I completed! ' . $response->getBody();
|
||||||
|
});
|
||||||
|
|
||||||
|
echo "before waiting for response" . PHP_EOL;
|
||||||
|
|
||||||
|
$promise->wait();
|
||||||
|
|
||||||
|
echo "after waiting for response" . PHP_EOL;
|
||||||
Reference in New Issue
Block a user