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

Improvements #249

Merged
merged 7 commits into from
Feb 7, 2024
Merged
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
5 changes: 0 additions & 5 deletions .build/object-manager.php

This file was deleted.

7 changes: 7 additions & 0 deletions .build/phpstan-doctrine.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php declare(strict_types = 1);

require __DIR__ . '/../vendor/autoload.php';

return App\Bootstrap::boot()
->createContainer()
->getByType(Doctrine\ORM\EntityManagerInterface::class);
5 changes: 5 additions & 0 deletions .docker/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM nginx:alpine
COPY ./ /var/www/html/
CMD ["nginx"]

EXPOSE 80 443
3 changes: 3 additions & 0 deletions .docker/nginx/conf.d/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
upstream php-upstream {
server php:9000;
}
24 changes: 24 additions & 0 deletions .docker/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
user nginx;
worker_processes 4;
daemon off;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

access_log /dev/stdout;
error_log /dev/stderr;

sendfile on;
keepalive_timeout 65;

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-available/*.conf;
}
28 changes: 28 additions & 0 deletions .docker/nginx/sites/default.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
server {

listen 80 default_server;
listen [::]:80 default_server ipv6only=on;

server_name localhost;
root /var/www/html/www/;
index index.php;

location / {
try_files $uri $uri/ /index.php$is_args$args;
}

location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass php-upstream;
fastcgi_index index.php;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 600;
include fastcgi_params;
}

location ~ /\.ht {
deny all;
}
}
9 changes: 9 additions & 0 deletions .docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM thecodingmachine/php:8.1-v4-fpm

COPY ./ /var/www/html/

WORKDIR /var/www/html/

CMD ["php-fpm"]

EXPOSE 9000
6 changes: 3 additions & 3 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

strategy:
matrix:
php-versions: [ "8.0" ]
php-versions: [ "8.1" ]
operating-system: [ "ubuntu-latest" ]
fail-fast: false

Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:

strategy:
matrix:
php-versions: [ "8.0" ]
php-versions: [ "8.1" ]
operating-system: [ "ubuntu-latest" ]
fail-fast: false

Expand Down Expand Up @@ -138,7 +138,7 @@ jobs:

strategy:
matrix:
php-versions: [ "8.0" ]
php-versions: [ "8.1", "8.2", "8.3" ]
operating-system: [ "ubuntu-latest" ]
fail-fast: false

Expand Down
53 changes: 32 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,46 +1,58 @@
############################################################
# PROJECT ##################################################
############################################################
.PHONY: project install setup clean

.PHONY: project
project: install setup

.PHONY: init
init:
cp config/local.neon.example config/local.neon

.PHONY: install
install:
composer install

.PHONY: setup
setup:
mkdir -p var/tmp var/log
chmod +0777 var/tmp var/log

.PHONY: clean
clean:
find var/tmp -mindepth 1 ! -name '.gitignore' -type f,d -exec rm -rf {} +
find var/log -mindepth 1 ! -name '.gitignore' -type f,d -exec rm -rf {} +

############################################################
# DEVELOPMENT ##############################################
############################################################
.PHONY: qa dev cs csf phpstan tests coverage dev build

.PHONY: qa
qa: cs phpstan

.PHONY: cs
cs:
vendor/bin/codesniffer app tests

.PHONY: csf
csf:
vendor/bin/codefixer app tests

.PHONY: phpstan
phpstan:
vendor/bin/phpstan analyse -c phpstan.neon --memory-limit=512M app tests/toolkit
vendor/bin/phpstan analyse -c phpstan.neon --memory-limit=512M

.PHONY: tests
tests:
vendor/bin/tester -s -p php --colors 1 -C tests

.PHONY: coverage
coverage:
vendor/bin/tester -s -p phpdbg --colors 1 -C --coverage ./coverage.xml --coverage-src ./app tests

.PHONY: dev
dev:
NETTE_DEBUG=1 NETTE_ENV=dev php -S 0.0.0.0:8000 -t www

.PHONY: build
build:
NETTE_DEBUG=1 bin/console orm:schema-tool:drop --force --full-database
NETTE_DEBUG=1 bin/console migrations:migrate --no-interaction
Expand All @@ -50,7 +62,6 @@ build:
# DEPLOYMENT ###############################################
############################################################
.PHONY: deploy

deploy:
$(MAKE) clean
$(MAKE) project
Expand All @@ -60,18 +71,18 @@ deploy:
############################################################
# DOCKER ###################################################
############################################################
.PHONY: docker-postgres docker-postgres-stop docker-adminer docker-adminer-stop

docker-postgres: docker-postgres-stop
docker run -it -d -p 5432:5432 --name doctrine_postgres -e POSTGRES_PASSWORD=doctrine -e POSTGRES_USER=doctrine dockette/postgres:12

docker-postgres-stop:
docker stop doctrine_postgres || true
docker rm doctrine_postgres || true

docker-adminer: docker-adminer-stop
docker run -it -d -p 9999:80 --name doctrine_adminer dockette/adminer:dg

docker-adminer-stop:
docker stop doctrine_adminer || true
docker rm doctrine_adminer || true
.PHONY: docker-postgres
docker-postgres:
docker run \
-it \
-p 5432:5432 \
-e POSTGRES_PASSWORD=contributte \
-e POSTGRES_USER=contributte \
dockette/postgres:12

.PHONY: docker-adminer
docker-adminer:
docker run \
-it \
-p 9999:80 \
dockette/adminer:dg
43 changes: 37 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ Main goal is to provide best prepared starter-kit project for Nette developers.

Focused on:

- latest PHP 8.0
- PHP 8.1+
- `nette/*` packages
- Doctrine ORM via `nettrine/*`
- Symfony components via `contributte/*`
- codestyle checking via **CodeSniffer** and `ninjify/*`
- static analysing via **phpstan**
- unit / integration tests via **Nette Tester** and `ninjify/*`
- codestyle checking via **CodeSniffer** and `contributte/qa`
- static analysing via **phpstan** and `contributte/phpstan`
- unit / integration tests via **Nette Tester** and `contributte/tester`

## Demo

Expand All @@ -58,15 +58,15 @@ composer create-project -s dev contributte/doctrine-skeleton acme
composer create-project -s dev contributte/doctrine-skeleton
```

2) After that, you have to setup Postgres >= 12 database. You can start it manually or use docker image `postgres:12`.
2) After that, you have to setup Postgres >= 12 database. You can start it manually or use docker image `dockette/postgres:12`.

```
docker run -it -p 5432:5432 -e POSTGRES_PASSWORD=doctrine -e POSTGRES_USER=doctrine dockette/postgres:12
```

Or use make task, `make docker-postgres`.

3) Custom configuration file is located at `app/config/local.neon`. Edit it if you want.
3) Custom configuration file is located at `config/local.neon`. Edit it if you want.

Default configuration should look like:

Expand All @@ -93,6 +93,37 @@ composer create-project -s dev contributte/doctrine-skeleton acme

6) Open http://localhost:8000 and enjoy!

### Install using [docker-compose](https://https://github.com/docker/compose/)

1) At first, use composer to install this project.

```
composer create-project -s dev contributte/webapp-project
```

2) Modify `config/local.neon` and set host to `database`

Default configuration should look like this:

```neon
# Host Config
parameters:
# Database
database:
host: database
dbname: contributte
user: contributte
password: contributte
```

3) Run `docker-compose up`

4) Open http://localhost and enjoy!

Take a look at:
- http://localhost.
- http://localhost/admin ([email protected] / admin)

### Composer packages

Take a detailed look :eyes: at each single package.
Expand Down
2 changes: 1 addition & 1 deletion app/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App;

use Contributte\Bootstrap\ExtraConfigurator;
use Nette\Configurator;
use Nette\Bootstrap\Configurator;

class Bootstrap
{
Expand Down
Loading
Loading