-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
philippe
committed
Dec 29, 2019
1 parent
b69b0d9
commit e2b90cb
Showing
25 changed files
with
1,028 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{ | ||
"name": "philippe-vandermoere/skeleton", | ||
"type": "project", | ||
"license": "MIT", | ||
"minimum-stability": "stable", | ||
"require": { | ||
"php": "^7.4", | ||
"ext-ctype": "*", | ||
"ext-iconv": "*", | ||
"ext-json": "*", | ||
"symfony/flex": "^1.6" | ||
}, | ||
"flex-require": { | ||
"symfony/console": "*", | ||
"symfony/dotenv": "*", | ||
"symfony/expression-language": "*", | ||
"symfony/framework-bundle": "*", | ||
"symfony/http-client": "*", | ||
"symfony/monolog-bundle": "^3.5", | ||
"symfony/orm-pack": "^1.0", | ||
"symfony/yaml": "*" | ||
}, | ||
"flex-require-dev": { | ||
"phpstan/phpstan": "^0.12", | ||
"phpstan/phpstan-doctrine": "^0.12", | ||
"phpstan/phpstan-phpunit": "^0.12", | ||
"phpstan/phpstan-symfony": "^0.12", | ||
"phpunit/phpunit": "^8.5", | ||
"squizlabs/php_codesniffer": "^3.5", | ||
"symfony/maker-bundle": "^1.0" | ||
}, | ||
"config": { | ||
"optimize-autoloader": true, | ||
"preferred-install": { | ||
"*": "dist" | ||
}, | ||
"sort-packages": true | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"App\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"App\\Tests\\": "tests/" | ||
} | ||
}, | ||
"replace": { | ||
"paragonie/random_compat": "2.*", | ||
"symfony/polyfill-ctype": "*", | ||
"symfony/polyfill-iconv": "*", | ||
"symfony/polyfill-php72": "*", | ||
"symfony/polyfill-php71": "*", | ||
"symfony/polyfill-php70": "*", | ||
"symfony/polyfill-php56": "*" | ||
}, | ||
"scripts": { | ||
"auto-scripts":[ | ||
], | ||
"post-install-cmd": [ | ||
"@auto-scripts" | ||
], | ||
"post-update-cmd": [ | ||
"@auto-scripts" | ||
], | ||
"post-create-project-cmd": [ | ||
"./post_create_project.sh" | ||
] | ||
}, | ||
"conflict": { | ||
"symfony/symfony": "*" | ||
}, | ||
"extra": { | ||
"symfony": { | ||
"allow-contrib": true, | ||
"require": "^5.0" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
readonly GREEN='\e[0;32m' | ||
readonly RESET='\e[0m' | ||
|
||
readonly PROJECT_FOLDER=$(realpath "$(dirname "$0")") | ||
readonly PROJECT_NAME=$(basename "${PROJECT_FOLDER}") | ||
readonly PROJECT_DEV_URL="${PROJECT_NAME,,}.philou.dev" | ||
|
||
cp -rpf "${PROJECT_FOLDER}/skeleton/". "${PROJECT_FOLDER}/" | ||
|
||
rm -f "${PROJECT_FOLDER}/config/services.yaml" | ||
rm -f "${PROJECT_FOLDER}/config/routes.yaml" | ||
|
||
echo -e "${GREEN}Update config files${RESET}" | ||
for file in README.md docs/DOCKER.md docker/dev/.env.dist; do | ||
if [[ -w "${PROJECT_FOLDER}/${file}" ]]; then | ||
sed s/skeleton_name/${PROJECT_NAME}/g -i "${PROJECT_FOLDER}/${file}" | ||
sed s/skeleton_url/${PROJECT_DEV_URL}/g -i "${PROJECT_FOLDER}/${file}" | ||
fi | ||
done | ||
|
||
echo -e "${GREEN}Remove post-create-project-cmd in composer.json${RESET}" | ||
readonly TMP_COMPOSER_FILE=$(mktemp) | ||
mv "${PROJECT_FOLDER}/composer.json" "${TMP_COMPOSER_FILE}" | ||
cat "${TMP_COMPOSER_FILE}" | jq 'del(.scripts."post-create-project-cmd")' --indent 4 > "${PROJECT_FOLDER}/composer.json" | ||
rm -f "${TMP_COMPOSER_FILE}" | ||
|
||
echo -e "${GREEN}Remove Skeleton files${RESET}" | ||
rm -rf "${PROJECT_FOLDER}/skeleton" | ||
rm -f "$0" | ||
|
||
echo -e "${GREEN}Update .gitignore${RESET}" | ||
echo '/.idea' >> "${PROJECT_FOLDER}/.gitignore" | ||
echo '/docker/.env' >> "${PROJECT_FOLDER}/.gitignore" | ||
|
||
echo -e "${GREEN}Initialize GIT repository for ${PROJECT_NAME^}${RESET}" | ||
cd ${PROJECT_FOLDER} | ||
git init -q | ||
git add . | ||
git commit -m "bootstrap project ${PROJECT_NAME}" -q |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
version: '2.1' | ||
commands: | ||
alpine_checkout: | ||
description: Optimize Alpine checkout. | ||
steps: | ||
- run: | ||
name: Install alpine requirements | ||
command: apk add git openssh-client curl make | ||
- checkout | ||
|
||
executors: | ||
php: | ||
docker: | ||
- image: php:7.4-cli-alpine | ||
|
||
jobs: | ||
vendor: | ||
executor: php | ||
working_directory: ~/repo | ||
steps: | ||
- alpine_checkout | ||
- restore_cache: | ||
key: vendor-{{ checksum "composer.json" }}-{{ checksum "composer.lock" }} | ||
- run: | ||
name: composer | ||
command: | | ||
if [[ ! -f vendor/autoload.php ]]; then | ||
curl --location --silent https://getcomposer.org/composer.phar -o /usr/bin/composer; \ | ||
chmod +x /usr/bin/composer; \ | ||
composer global require hirak/prestissimo; \ | ||
composer install --no-progress --no-interaction; \ | ||
fi | ||
- save_cache: | ||
key: vendor-{{ checksum "composer.json" }}-{{ checksum "composer.lock" }} | ||
paths: | ||
- vendor | ||
- persist_to_workspace: | ||
root: . | ||
paths: | ||
- vendor | ||
|
||
phpcs: | ||
executor: php | ||
working_directory: ~/repo | ||
steps: | ||
- alpine_checkout | ||
- attach_workspace: | ||
at: . | ||
- run: | ||
name: phpcs | ||
command: make phpcs | ||
|
||
phpstan: | ||
executor: php | ||
working_directory: ~/repo | ||
steps: | ||
- alpine_checkout | ||
- attach_workspace: | ||
at: . | ||
- run: | ||
name: phpstan | ||
command: make phpstan | ||
|
||
phpunit: | ||
executor: php | ||
working_directory: ~/repo | ||
steps: | ||
- alpine_checkout | ||
- attach_workspace: | ||
at: . | ||
- run: | ||
name: phpunit | ||
command: make phpunit options="--log-junit ~/phpunit/junit.xml --coverage-html ~/coverage-html" | ||
- store_artifacts: | ||
path: ~/coverage-html | ||
destination: coverage-html | ||
- store_artifacts: | ||
path: ~/phpunit | ||
destination: phpunit | ||
- store_test_results: | ||
path: ~/phpunit | ||
|
||
workflows: | ||
version: '2.1' | ||
tests: | ||
jobs: | ||
- vendor | ||
- phpcs: | ||
requires: | ||
- vendor | ||
- phpstan: | ||
requires: | ||
- vendor | ||
- phpunit: | ||
requires: | ||
- vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
charset = utf-8 | ||
|
||
[Makefile] | ||
indent_style = tab | ||
|
||
[*.{php,less,js,yml,yaml}] | ||
indent_style = space | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2020 Philippe VANDERMOERE | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
ifndef VERBOSE | ||
MAKEFLAGS += --no-print-directory | ||
endif | ||
|
||
default: | ||
|
||
phpcs: | ||
vendor/bin/phpcs | ||
|
||
phpstan: | ||
APP_ENV=test bin/console cache:clear | ||
vendor/bin/phpstan analyse | ||
|
||
phpunit: | ||
phpdbg -qrr vendor/bin/phpunit $(options) | ||
|
||
tests: phpcs phpstan phpunit | ||
|
||
install: | ||
composer install | ||
bin/console doctrine:database:create --no-interaction --if-not-exists | ||
bin/console doctrine:migrations:migrate --no-interaction --query-time --allow-no-migration | ||
|
||
.out_docker: | ||
ifeq (, $(shell which docker)) | ||
$(error "You must run this command outside the docker container. ") | ||
endif | ||
|
||
start: .out_docker | ||
$(shell docker/dev/configure.sh) | ||
@cd docker/dev && docker-compose build --pull --parallel --quiet | ||
@cd docker/dev && docker-compose up --detach --remove-orphans --quiet-pull --scale nginx=2 --scale php-fpm=2 | ||
@cd docker/dev && docker-compose exec php-fpm make .waiting_for_dependency | ||
@cd docker/dev && docker-compose exec php-fpm make install | ||
|
||
.waiting_for_dependency: | ||
@make .waiting_for service=mysql port=3306 timeout=30 | ||
|
||
.waiting_for: | ||
@echo -e "\e[1;33mWaiting for $(service) is Ready\e[0m" | ||
@/bin/sh -c 'for i in `seq 1 $(timeout)`;do nc $(service) $(port) -w 1 -z && exit 0;sleep 1;done;exit 1' | ||
@echo -e "\e[1;32m$(service) is ready\e[0m" | ||
|
||
stop: .out_docker | ||
@cd docker/dev && docker-compose stop | ||
|
||
remove: .out_docker | ||
@cd docker/dev && docker-compose down --remove-orphans --volumes | ||
|
||
restart: .out_docker | ||
@cd docker/dev && docker-compose restart | ||
|
||
ps: .out_docker | ||
@cd docker/dev && docker-compose ps | ||
|
||
shell: .out_docker | ||
@cd docker/dev && docker-compose exec php-fpm /bin/bash | ||
|
||
mysql_cli: .out_docker | ||
@cd docker/dev && docker-compose exec mysql /bin/bash -c 'mysql -uroot -p$${MYSQL_ROOT_PASSWORD} $${MYSQL_DATABASE}' | ||
|
||
redis_cli: .out_docker | ||
@cd docker/dev && docker-compose exec redis redis-cli | ||
|
||
logs: .out_docker | ||
@cd docker/dev && docker-compose logs --timestamps --follow --tail=50 $(service) | ||
|
||
logs_php-nginx: | ||
@make logs service=nginx | ||
|
||
logs_php-fpm: | ||
@make logs service=php-fpm | ||
|
||
logs_mysql: | ||
@make logs service=mysql | ||
|
||
logs_redis: | ||
@make logs service=redis | ||
|
||
logs_rabbitmq: | ||
@make logs service=rabbitmq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# skeleton_name | ||
|
||
## Development | ||
|
||
### Installation | ||
|
||
- [with Docker](docs/DOCKER.md) (recommended) | ||
|
||
### Tests | ||
|
||
Run all tests: | ||
- PHPCs | ||
- PHPStan | ||
- PHPUnit | ||
|
||
```bash | ||
make tests | ||
``` | ||
|
||
Run PHPCs tests: | ||
|
||
```bash | ||
make phpcs | ||
``` | ||
|
||
Run PHPStan tests: | ||
|
||
```bash | ||
make phpstan | ||
``` | ||
|
||
Run PHPUnit tests: | ||
|
||
```bash | ||
make phpunit | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
services: | ||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
|
||
App\Controller\: | ||
resource: '../../src/Controller' | ||
tags: ['controller.service_arguments'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
COMPOSE_PROJECT_NAME=skeleton_name | ||
HTTP_HOST=skeleton_url | ||
DOCKER_UID= | ||
GITHUB_TOKEN= | ||
GITHUB_CERTIFICATES_REPOSITORY= | ||
TIMEZONE=Europe/Paris | ||
MYSQL_ROOT_PASSWORD=root | ||
MYSQL_DATABASE=test | ||
MYSQL_USER=test | ||
MYSQL_PASSWORD=test | ||
AMQP_USER=test | ||
AMQP_PASSWORD=test | ||
AMQP_VHOST=/ |
Oops, something went wrong.