Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hw3: added the external library #89

Open
wants to merge 3 commits into
base: APogorelov/main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
init: docker-down docker-build docker-up

docker-down:
docker compose down --remove-orphans

docker-build:
docker compose build

docker-up:
docker compose up -d
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": {
"alexander-pogorelov/date-time-helper": "^1.0"
}
}
49 changes: 49 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
version: '3'

services:
nginx:
image: nginx:latest
container_name: mysite-nginx
depends_on:
- php-fpm
ports:
- "80:80"
volumes:
- ./:/data/mysite.local
- ./nginx/hosts/mysite.local.conf:/etc/nginx/conf.d/mysite.local.conf
networks:
- app-network

php-fpm:
build:
context: ./fpm
dockerfile: Dockerfile
image: mysite/php-fpm
container_name: mysite-php-fpm
working_dir: /data/mysite.local
volumes:
- ./:/data/mysite.local
networks:
- app-network

networks:
app-network:
driver: bridge
20 changes: 20 additions & 0 deletions fpm/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM php:8.2-fpm

# ставим необходимые для нормальной работы модули
RUN apt-get update \
&& apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libonig-dev \
libzip-dev \
libz-dev \
libmcrypt-dev \
&& pecl install mcrypt-1.0.6 \
&& docker-php-ext-enable mcrypt \
&& docker-php-ext-install -j$(nproc) iconv mbstring mysqli pdo_mysql zip \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd

# Устанавливаем Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
25 changes: 25 additions & 0 deletions nginx/hosts/mysite.local.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
server {
listen 80;
server_name mysite.local;
root /data/mysite.local/public;
index index.php index.html;

location ~* .(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
}

location / {
try_files $uri $uri/ /index.php?$query_string;
}

location ~* .php$ {
try_files $uri = 404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass php-fpm:9000;
#fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
19 changes: 19 additions & 0 deletions public/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

use AlexanderPogorelov\DateTimeHelper\DateHelper;

require dirname(__DIR__) . '/vendor/autoload.php';

$timezone = 'Europe/Minsk';
$helper = new DateHelper();

$nowString = $helper->getCurrentDateMySQL($timezone);
$nowObject = $helper->createDateFromString($nowString, $timezone);

echo "<pre>";
echo 'Current Date in MySQL format:' . PHP_EOL;
echo $nowString;
echo "<hr>";
echo 'Current Date as DateTimeImmutable object:';
print_r($nowObject);
echo "</pre>";
Loading