diff --git a/.gitignore b/.gitignore index 9522a52..9edd69b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +/.idea/ /src/log/ /src/temp/ -/src/vendor/ \ No newline at end of file +/src/vendor/ diff --git a/Makefile b/Makefile index b1f2b3c..fcf04b0 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,11 @@ .PHONE composerValidate: composerValidate: cd ./src && composer validate --strict - + +.PHONE dockerComposeUp: +dockerComposeUp: + docker compose -p wb_assignment up -d + .PHONE phpstan: phpstan: cd ./src && composer phpstan \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1bb3d81 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,22 @@ +services: + api: + build: + dockerfile: ./docker/DockerfilePhp + ports: + - 8090:80 + volumes: + - ./docker/apache.conf:/etc/apache2/sites-available/000-default.conf + - ./src:/var/www/html + depends_on: + - database + + database: + image: mariadb:10.4 + container_name: database + environment: # Accepted security risk for sake of development speed + MYSQL_ROOT_PASSWORD: rootpassword + MYSQL_DATABASE: mydb + MYSQL_USER: myuser + MYSQL_PASSWORD: mypass + ports: + - "3306:3306" diff --git a/docker/DockerfilePhp b/docker/DockerfilePhp new file mode 100644 index 0000000..52bff57 --- /dev/null +++ b/docker/DockerfilePhp @@ -0,0 +1,13 @@ +FROM php:8.3-apache + +RUN apt-get update -y + +RUN apt-get install -y libicu-dev + +RUN docker-php-ext-install intl + +RUN docker-php-ext-install mysqli + +RUN a2enmod rewrite + +RUN service apache2 restart diff --git a/docker/apache.conf b/docker/apache.conf new file mode 100644 index 0000000..3a8ec4c --- /dev/null +++ b/docker/apache.conf @@ -0,0 +1,7 @@ + + ServerAdmin webmaster@localhost + DocumentRoot /var/www/html/www + + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + diff --git a/src/app/Bootstrap.php b/src/app/Bootstrap.php index 2073ebb..a7a9306 100644 --- a/src/app/Bootstrap.php +++ b/src/app/Bootstrap.php @@ -1,6 +1,6 @@ = 8.3", + "dibi/dibi": "^5.1", + "latte/latte": "^3.0", "nette/application": "^3.2.3", "nette/assets": "^1.0.0", "nette/bootstrap": "^3.2.6", @@ -17,7 +19,6 @@ "nette/robot-loader": "^4.0", "nette/security": "^3.2", "nette/utils": "^4.0", - "latte/latte": "^3.0", "tracy/tracy": "^2.10" }, "require-dev": { @@ -31,11 +32,12 @@ }, "autoload": { "psr-4": { - "App\\": "app" + "WbAssignment\\": "app" } }, "scripts": { "phpstan": "phpstan analyse -c ../phpstan.neon", + "server": "cd ./www && php -S localhost:8005", "tester": "tester tests -s" }, "minimum-stability": "stable", diff --git a/src/composer.lock b/src/composer.lock index eeb804d..0818168 100644 --- a/src/composer.lock +++ b/src/composer.lock @@ -4,8 +4,82 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ed24e22e05daeaa8f7f7ef0c04598c18", + "content-hash": "ba1c3e5390d38a49e86932890ac01656", "packages": [ + { + "name": "dibi/dibi", + "version": "v5.1.0", + "source": { + "type": "git", + "url": "https://github.com/dg/dibi.git", + "reference": "32b6976209859f61eb79380c5a8904ea33db47df" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dg/dibi/zipball/32b6976209859f61eb79380c5a8904ea33db47df", + "reference": "32b6976209859f61eb79380c5a8904ea33db47df", + "shasum": "" + }, + "require": { + "php": "8.2 - 8.5" + }, + "replace": { + "dg/dibi": "*" + }, + "require-dev": { + "jetbrains/phpstorm-attributes": "^1.0", + "nette/di": "^3.1", + "nette/tester": "^2.5", + "phpstan/phpstan-nette": "^2.0@stable", + "tracy/tracy": "^2.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-dev" + } + }, + "autoload": { + "psr-4": { + "Dibi\\": "src/Dibi" + }, + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0-only", + "GPL-3.0-only" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + } + ], + "description": "Dibi is Database Abstraction Library for PHP", + "homepage": "https://dibiphp.com", + "keywords": [ + "access", + "database", + "dbal", + "mssql", + "mysql", + "odbc", + "oracle", + "pdo", + "postgresql", + "sqlite", + "sqlsrv" + ], + "support": { + "issues": "https://github.com/dg/dibi/issues", + "source": "https://github.com/dg/dibi/tree/v5.1.0" + }, + "time": "2025-08-06T22:26:19+00:00" + }, { "name": "latte/latte", "version": "v3.0.23", diff --git a/src/config/common.neon b/src/config/common.neon index 804581f..7380b1f 100644 --- a/src/config/common.neon +++ b/src/config/common.neon @@ -1,13 +1,20 @@ # see https://doc.nette.org/en/configuring parameters: + dibi: # Accepted security risk for sake of development speed + host: database + port: 3306 + database: mydb + user: myuser + password: mypass + lazy: TRUE application: errorPresenter: 4xx: Error:Error4xx 5xx: Error:Error5xx - mapping: App\Presentation\*\**Presenter + mapping: WbAssignment\Presentation\*\**Presenter database: @@ -20,7 +27,7 @@ latte: strictTypes: yes strictParsing: yes extensions: - - App\Presentation\Accessory\LatteExtension + - WbAssignment\Presentation\Accessory\LatteExtension assets: @@ -34,3 +41,10 @@ di: export: parameters: no tags: no + + +dibi: %dibi% + + +extensions: + dibi: Dibi\Bridges\Nette\DibiExtension22 diff --git a/src/config/services.neon b/src/config/services.neon index 67302ee..2e183df 100644 --- a/src/config/services.neon +++ b/src/config/services.neon @@ -1,5 +1,5 @@ services: - - App\Core\RouterFactory::createRouter + - WbAssignment\Core\RouterFactory::createRouter search: diff --git a/src/www/index.php b/src/www/index.php index 4acf7d5..f372650 100644 --- a/src/www/index.php +++ b/src/www/index.php @@ -2,7 +2,7 @@ require __DIR__ . '/../vendor/autoload.php'; -$bootstrap = new App\Bootstrap; +$bootstrap = new WbAssignment\Bootstrap; $container = $bootstrap->bootWebApplication(); $application = $container->getByType(Nette\Application\Application::class); $application->run();