Skip to content

Commit

Permalink
Merge pull request #10 from sunrise-php/release/v3.0.0
Browse files Browse the repository at this point in the history
v3.0.0
  • Loading branch information
fenric committed Feb 7, 2021
2 parents d1b72a2 + 48f1217 commit 68b5a88
Show file tree
Hide file tree
Showing 75 changed files with 5,636 additions and 2,542 deletions.
30 changes: 30 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# PHP CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-php/ for more details
#
version: 2
jobs:
php74:
docker:
- image: circleci/php:7.4-cli-node-browsers
steps:
- checkout
- run: php -v
- run: cp .env.example .env
- run: composer install --no-interaction --prefer-source --no-suggest
- run: php vendor/bin/phpunit --colors=always
php80:
docker:
- image: circleci/php:8.0-cli-node-browsers
steps:
- checkout
- run: php -v
- run: cp .env.example .env
- run: composer install --no-interaction --prefer-source --no-suggest
- run: php vendor/bin/phpunit --colors=always
workflows:
version: 2
build:
jobs:
- php74
- php80
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,5 @@ indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
55 changes: 44 additions & 11 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,14 +1,47 @@
APP_ENV=dev
APP_DISPLAY_ERRORS=1
#
# The application URL
#
# Must contain scheme, host and port (if not standard)
#
APP_URL="http://localhost:3000"

DATABASE_URL="mysql://user:[email protected]:3306/acme"
#
# The application environment
#
# Use only the following values: dev, test, stage or prod
#
APP_ENV="dev"

#
# If set to 1, debug info will be logged
#
# In the production MUST be set to 0
#
APP_DEBUG=1

#
# If set to 1, fatal errors will not be displayed
#
# In the production MUST be set to 1
#
APP_SILENT=0

#
# Database server address to which you will write
#
DB_MASTER_URL="mysql://user:password@localhost:3306/acme?charset=utf8mb4"

#
# Database server address from which you will read
#
# If replication is not configured, just duplicate the address of the master server
#
DB_SLAVE_URL="mysql://user:password@localhost:3306/acme?charset=utf8mb4"

#
# Telegram logging
#
TELEGRAM_URL="https://api.telegram.org"
TELEGRAM_TOKEN=
TELEGRAM_RECIPIENT=
TELEGRAM_LEVEL=ERROR

CORS_DEBUG=1
CORS_SERVER_ORIGIN_SCHEME=http
CORS_SERVER_ORIGIN_HOST="127.0.0.1"
CORS_SERVER_ORIGIN_PORT=3000
TELEGRAM_TOKEN=""
TELEGRAM_RECIPIENT=""
TELEGRAM_LEVEL="ERROR"
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.php.dev linguist-language=PHP
*.php.test linguist-language=PHP
*.php.stage linguist-language=PHP
*.php.prod linguist-language=PHP
*.php.local linguist-language=PHP
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
/.down
/.env
/.php_cs.cache
/.phpunit.result.cache
/.rr.yml
/coverage.xml
/phpbench.json
/phpcs.xml
/phpunit.xml
/cache/*
/config/definitions/*.php.local
/tests/db/*.sqlite
/vendor/
!.gitkeep
4 changes: 2 additions & 2 deletions .rr.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ rpc:
http:
address: 0.0.0.0:3000
workers:
command: "php bin/roadrunner-worker pipes"
command: "php bin/worker-roadrunner pipes"
pool:
numWorkers: 4
maxJobs: 0
maxJobs: 1000
7 changes: 7 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
build:
environment:
php:
version: '8.0'
ini:
'xdebug.mode': 'coverage'
nodes:
analysis:
tests:
override:
- php-scrutinizer-run
coverage:
tests:
before:
- command: cp .env.example .env
override:
- command: php vendor/bin/phpunit --coverage-clover coverage.xml
coverage:
Expand Down
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

115 changes: 107 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## Awesome Skeleton for modern development on PHP 7.3+
## Awesome Skeleton for modern development on PHP 7.4+ (incl. PHP 8)

[![Build Status](https://scrutinizer-ci.com/g/sunrise-php/awesome-skeleton/badges/build.png?b=master)](https://scrutinizer-ci.com/g/sunrise-php/awesome-skeleton/build-status/master)
> Contains quality tested packages, thoughtful structure and everything you need to develop microservices.
[![Build Status](https://circleci.com/gh/sunrise-php/awesome-skeleton.svg?style=shield)](https://circleci.com/gh/sunrise-php/awesome-skeleton)
[![Code Coverage](https://scrutinizer-ci.com/g/sunrise-php/awesome-skeleton/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/sunrise-php/awesome-skeleton/?branch=master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/sunrise-php/awesome-skeleton/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/sunrise-php/awesome-skeleton/?branch=master)
[![Total Downloads](https://poser.pugx.org/sunrise/awesome-skeleton/downloads?format=flat)](https://packagist.org/packages/sunrise/awesome-skeleton)
Expand All @@ -15,9 +17,23 @@
composer create-project 'sunrise/awesome-skeleton:^3.0' app
```

## Cooking

Set up your database connection:

```bash
cp .env.example .env && nano .env
```

Execute a migration:

```bash
php bin/app migrations:migrate --service 'master' --no-interaction
```

## Run CLI

> including: Doctrine DBAL, Doctrine ORM, Doctrine Migrations.
> incl.: Doctrine DBAL, Doctrine ORM, Doctrine Migrations.
```bash
php bin/app
Expand All @@ -35,10 +51,22 @@ composer serve

> listen 0.0.0.0:3000
Set up your server:

```bash
cp .rr.yml.example .rr.yml && nano .rr.yml
```

Run the server:

```bash
rr -dv serve
```

## Run via Swoole

> Coming soon...
## Run tests

```bash
Expand All @@ -53,9 +81,81 @@ composer bench

---

## Run routes through cURL

> you may need to change the server address...
#### Home (index)

```bash
curl -X 'GET' 'http://127.0.0.1:3000/'
```

#### OpenAPI document

```bash
curl -X 'GET' 'http://127.0.0.1:3000/openapi'
```

#### Create an entry (example bundle)

```bash
curl -X 'POST' -H 'Content-Type: application/json' -d '{"name": "foo", "slug": "foo"}' 'http://127.0.0.1:3000/api/v1/entry'
```

#### Update an existing entry (example bundle)

> you need to set an existing ID.
```bash
curl -X 'PATCH' -H 'Content-Type: application/json' -d '{"name": "foo", "slug": "foo"}' 'http://127.0.0.1:3000/api/v1/entry/b06fd41d-d131-4bb9-a472-eb583369437c'
```

#### Delete an existing entry (example bundle)

> you need to set an existing ID.
```bash
curl -X 'DELETE' 'http://127.0.0.1:3000/api/v1/entry/b06fd41d-d131-4bb9-a472-eb583369437c'
```

#### Read an existing entry (example bundle)

> you need to set an existing ID.
```bash
curl -X 'GET' 'http://127.0.0.1:3000/api/v1/entry/b06fd41d-d131-4bb9-a472-eb583369437c'
```

#### List of entries (example bundle)

```bash
curl -X 'GET' 'http://127.0.0.1:3000/api/v1/entry'
```

---

## Useful commands

#### Generate Systemd unit file for RoadRunner
#### Deploy

```bash
bash bin/deploy
```

#### Down

```bash
bash bin/down 'Reason...'
```

#### Up

```bash
bash bin/up
```

#### Generate Systemd unit for RoadRunner

```bash
php bin/app app:roadrunner:generate-systemd-unit > app.service
Expand All @@ -64,24 +164,23 @@ php bin/app app:roadrunner:generate-systemd-unit > app.service
#### Generate OpenApi document

```bash
php bin/app app:openapi:generate-documentation --pretty > openapi.json
php bin/app app:openapi:generate-document > openapi.json
```

---

## Used stack

> see composer.json
* https://github.com/PHP-DI/PHP-DI
* https://github.com/Seldaek/monolog
* https://github.com/sunrise-php/http-router
* https://github.com/doctrine/orm
* https://github.com/doctrine/migrations
* https://github.com/symfony/console
* https://github.com/symfony/validator
* https://github.com/neomerx/cors-psr7
* https://github.com/justinrainbow/json-schema
* https://github.com/filp/whoops
* https://github.com/twigphp/Twig

## Used technology

Expand Down
4 changes: 0 additions & 4 deletions bin/app
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,4 @@ $application->addCommands(
$container->get('commands')
);

$application->addCommands(
$container->get('doctrine')->getCommands()
);

$application->run();
14 changes: 14 additions & 0 deletions bin/deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

bash bin/down 'deploying'

git fetch --tags
git checkout $(git describe --tags $(git rev-list --tags --max-count=1))

find cache/ -type f -not -name '.gitkeep' -delete
composer install --no-dev --classmap-authoritative

php bin/app migrations:migrate --service 'master' --no-interaction
php bin/app orm:generate-proxies --service 'master'

bash bin/up
3 changes: 3 additions & 0 deletions bin/down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

echo $1 > .down
3 changes: 3 additions & 0 deletions bin/up
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

rm -f .down
11 changes: 11 additions & 0 deletions bin/version
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

VERSION=$(git describe --tags --abbrev=0 2> /dev/null)

if [ $? -eq 0 ]; then
echo $VERSION | sed 's/^v//'
else
echo '0.1.0-dev'
fi

exit 0
8 changes: 3 additions & 5 deletions bin/roadrunner-worker → bin/worker-roadrunner
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ $client = new Client(
);

while ($request = $client->acceptRequest()) {
$doctrine->reopenManagers();
$handler = new QueueableRequestHandler($router);
$handler->add(...$middlewares);

$doctrine->reopenManagers();

$client->respond($handler->handle($request));

$response = $handler->handle($request);
$client->respond($response);
$doctrine->clearManagers();
$doctrine->closeConnections();
}
4 changes: 4 additions & 0 deletions bin/worker-swoole
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env php
<?php

echo 'Coming soon...', PHP_EOL;
File renamed without changes.
Loading

0 comments on commit 68b5a88

Please sign in to comment.