-
Notifications
You must be signed in to change notification settings - Fork 127
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
gzydong
committed
Nov 2, 2020
0 parents
commit ec714fd
Showing
52 changed files
with
1,794 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,17 @@ | ||
APP_NAME=skeleton | ||
APP_ENV=dev | ||
|
||
DB_DRIVER=mysql | ||
DB_HOST=localhost | ||
DB_PORT=3306 | ||
DB_DATABASE=hyperf | ||
DB_USERNAME=root | ||
DB_PASSWORD= | ||
DB_CHARSET=utf8mb4 | ||
DB_COLLATION=utf8mb4_unicode_ci | ||
DB_PREFIX= | ||
|
||
REDIS_HOST=localhost | ||
REDIS_AUTH=(null) | ||
REDIS_PORT=6379 | ||
REDIS_DB=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,60 @@ | ||
# Default Dockerfile | ||
# | ||
# @link https://www.hyperf.io | ||
# @document https://hyperf.wiki | ||
# @contact [email protected] | ||
# @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE | ||
|
||
FROM hyperf/hyperf:7.4-alpine-v3.11-cli | ||
LABEL maintainer="Hyperf Developers <[email protected]>" version="1.0" license="MIT" app.name="Hyperf" | ||
|
||
## | ||
# ---------- env settings ---------- | ||
## | ||
# --build-arg timezone=Asia/Shanghai | ||
ARG timezone | ||
|
||
ENV TIMEZONE=${timezone:-"Asia/Shanghai"} \ | ||
COMPOSER_VERSION=1.10.10 \ | ||
APP_ENV=prod \ | ||
SCAN_CACHEABLE=(true) | ||
|
||
# update | ||
RUN set -ex \ | ||
# install composer | ||
&& cd /tmp \ | ||
&& wget https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar \ | ||
&& chmod u+x composer.phar \ | ||
&& mv composer.phar /usr/local/bin/composer \ | ||
# show php version and extensions | ||
&& php -v \ | ||
&& php -m \ | ||
&& php --ri swoole \ | ||
# ---------- some config ---------- | ||
&& cd /etc/php7 \ | ||
# - config PHP | ||
&& { \ | ||
echo "upload_max_filesize=128M"; \ | ||
echo "post_max_size=128M"; \ | ||
echo "memory_limit=1G"; \ | ||
echo "date.timezone=${TIMEZONE}"; \ | ||
} | tee conf.d/99_overrides.ini \ | ||
# - config timezone | ||
&& ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \ | ||
&& echo "${TIMEZONE}" > /etc/timezone \ | ||
# ---------- clear works ---------- | ||
&& rm -rf /var/cache/apk/* /tmp/* /usr/share/man \ | ||
&& echo -e "\033[42;37m Build Completed :).\033[0m\n" | ||
|
||
WORKDIR /opt/www | ||
|
||
# Composer Cache | ||
# COPY ./composer.* /opt/www/ | ||
# RUN composer install --no-dev --no-scripts | ||
|
||
COPY . /opt/www | ||
RUN print "\n" | composer install -o && php bin/hyperf.php | ||
|
||
EXPOSE 9501 | ||
|
||
ENTRYPOINT ["php", "/opt/www/bin/hyperf.php", "start"] |
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 @@ | ||
name: Build Docker | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Build | ||
run: cp -rf .github/workflows/Dockerfile . && docker build -t hyperf . |
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,25 @@ | ||
on: | ||
push: | ||
# Sequence of patterns matched against refs/tags | ||
tags: | ||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | ||
|
||
name: Release | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
draft: false | ||
prerelease: false |
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 @@ | ||
.buildpath | ||
.settings/ | ||
.project | ||
*.patch | ||
.idea/ | ||
.git/ | ||
runtime/ | ||
vendor/ | ||
.phpintel/ | ||
.env | ||
.DS_Store | ||
*.lock | ||
.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,57 @@ | ||
# usermod -aG docker gitlab-runner | ||
|
||
stages: | ||
- build | ||
- deploy | ||
|
||
variables: | ||
PROJECT_NAME: hyperf | ||
REGISTRY_URL: registry-docker.org | ||
|
||
build_test_docker: | ||
stage: build | ||
before_script: | ||
# - git submodule sync --recursive | ||
# - git submodule update --init --recursive | ||
script: | ||
- docker build . -t $PROJECT_NAME | ||
- docker tag $PROJECT_NAME $REGISTRY_URL/$PROJECT_NAME:test | ||
- docker push $REGISTRY_URL/$PROJECT_NAME:test | ||
only: | ||
- test | ||
tags: | ||
- builder | ||
|
||
deploy_test_docker: | ||
stage: deploy | ||
script: | ||
- docker stack deploy -c deploy.test.yml --with-registry-auth $PROJECT_NAME | ||
only: | ||
- test | ||
tags: | ||
- test | ||
|
||
build_docker: | ||
stage: build | ||
before_script: | ||
# - git submodule sync --recursive | ||
# - git submodule update --init --recursive | ||
script: | ||
- docker build . -t $PROJECT_NAME | ||
- docker tag $PROJECT_NAME $REGISTRY_URL/$PROJECT_NAME:$CI_COMMIT_REF_NAME | ||
- docker tag $PROJECT_NAME $REGISTRY_URL/$PROJECT_NAME:latest | ||
- docker push $REGISTRY_URL/$PROJECT_NAME:$CI_COMMIT_REF_NAME | ||
- docker push $REGISTRY_URL/$PROJECT_NAME:latest | ||
only: | ||
- tags | ||
tags: | ||
- builder | ||
|
||
deploy_docker: | ||
stage: deploy | ||
script: | ||
- echo SUCCESS | ||
only: | ||
- tags | ||
tags: | ||
- builder |
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,91 @@ | ||
<?php | ||
|
||
$header = <<<'EOF' | ||
This file is part of Hyperf. | ||
@link https://www.hyperf.io | ||
@document https://hyperf.wiki | ||
@contact [email protected] | ||
@license https://github.com/hyperf/hyperf/blob/master/LICENSE | ||
EOF; | ||
|
||
return PhpCsFixer\Config::create() | ||
->setRiskyAllowed(true) | ||
->setRules([ | ||
'@PSR2' => true, | ||
'@Symfony' => true, | ||
'@DoctrineAnnotation' => true, | ||
'@PhpCsFixer' => true, | ||
'header_comment' => [ | ||
'commentType' => 'PHPDoc', | ||
'header' => $header, | ||
'separate' => 'none', | ||
'location' => 'after_declare_strict', | ||
], | ||
'array_syntax' => [ | ||
'syntax' => 'short' | ||
], | ||
'list_syntax' => [ | ||
'syntax' => 'short' | ||
], | ||
'concat_space' => [ | ||
'spacing' => 'one' | ||
], | ||
'blank_line_before_statement' => [ | ||
'statements' => [ | ||
'declare', | ||
], | ||
], | ||
'general_phpdoc_annotation_remove' => [ | ||
'annotations' => [ | ||
'author' | ||
], | ||
], | ||
'ordered_imports' => [ | ||
'imports_order' => [ | ||
'class', 'function', 'const', | ||
], | ||
'sort_algorithm' => 'alpha', | ||
], | ||
'single_line_comment_style' => [ | ||
'comment_types' => [ | ||
], | ||
], | ||
'yoda_style' => [ | ||
'always_move_variable' => false, | ||
'equal' => false, | ||
'identical' => false, | ||
], | ||
'phpdoc_align' => [ | ||
'align' => 'left', | ||
], | ||
'multiline_whitespace_before_semicolons' => [ | ||
'strategy' => 'no_multi_line', | ||
], | ||
'constant_case' => [ | ||
'case' => 'lower', | ||
], | ||
'class_attributes_separation' => true, | ||
'combine_consecutive_unsets' => true, | ||
'declare_strict_types' => true, | ||
'linebreak_after_opening_tag' => true, | ||
'lowercase_static_reference' => true, | ||
'no_useless_else' => true, | ||
'no_unused_imports' => true, | ||
'not_operator_with_successor_space' => true, | ||
'not_operator_with_space' => false, | ||
'ordered_class_elements' => true, | ||
'php_unit_strict' => false, | ||
'phpdoc_separation' => false, | ||
'single_quote' => true, | ||
'standardize_not_equals' => true, | ||
'multiline_comment_opening_closing' => true, | ||
]) | ||
->setFinder( | ||
PhpCsFixer\Finder::create() | ||
->exclude('public') | ||
->exclude('runtime') | ||
->exclude('vendor') | ||
->in(__DIR__) | ||
) | ||
->setUsingCache(false); |
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,11 @@ | ||
<?php | ||
|
||
namespace PHPSTORM_META { | ||
|
||
// Reflect | ||
override(\Psr\Container\ContainerInterface::get(0), map('@')); | ||
override(\Hyperf\Utils\Context::get(0), map('@')); | ||
override(\make(0), map('@')); | ||
override(\di(0), map('@')); | ||
|
||
} |
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,60 @@ | ||
# Default Dockerfile | ||
# | ||
# @link https://www.hyperf.io | ||
# @document https://hyperf.wiki | ||
# @contact [email protected] | ||
# @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE | ||
|
||
FROM hyperf/hyperf:7.4-alpine-v3.11-cli | ||
LABEL maintainer="Hyperf Developers <[email protected]>" version="1.0" license="MIT" app.name="Hyperf" | ||
|
||
## | ||
# ---------- env settings ---------- | ||
## | ||
# --build-arg timezone=Asia/Shanghai | ||
ARG timezone | ||
|
||
ENV TIMEZONE=${timezone:-"Asia/Shanghai"} \ | ||
COMPOSER_VERSION=1.10.10 \ | ||
APP_ENV=prod \ | ||
SCAN_CACHEABLE=(true) | ||
|
||
# update | ||
RUN set -ex \ | ||
# install composer | ||
&& cd /tmp \ | ||
&& wget https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar \ | ||
&& chmod u+x composer.phar \ | ||
&& mv composer.phar /usr/local/bin/composer \ | ||
# show php version and extensions | ||
&& php -v \ | ||
&& php -m \ | ||
&& php --ri swoole \ | ||
# ---------- some config ---------- | ||
&& cd /etc/php7 \ | ||
# - config PHP | ||
&& { \ | ||
echo "upload_max_filesize=128M"; \ | ||
echo "post_max_size=128M"; \ | ||
echo "memory_limit=1G"; \ | ||
echo "date.timezone=${TIMEZONE}"; \ | ||
} | tee conf.d/99_overrides.ini \ | ||
# - config timezone | ||
&& ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \ | ||
&& echo "${TIMEZONE}" > /etc/timezone \ | ||
# ---------- clear works ---------- | ||
&& rm -rf /var/cache/apk/* /tmp/* /usr/share/man \ | ||
&& echo -e "\033[42;37m Build Completed :).\033[0m\n" | ||
|
||
WORKDIR /opt/www | ||
|
||
# Composer Cache | ||
# COPY ./composer.* /opt/www/ | ||
# RUN composer install --no-dev --no-scripts | ||
|
||
COPY . /opt/www | ||
RUN composer install --no-dev -o && php bin/hyperf.php | ||
|
||
EXPOSE 9501 | ||
|
||
ENTRYPOINT ["php", "/opt/www/bin/hyperf.php", "start"] |
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 @@ | ||
# Introduction | ||
|
||
This is a skeleton application using the Hyperf framework. This application is meant to be used as a starting place for those looking to get their feet wet with Hyperf Framework. | ||
|
||
# Requirements | ||
|
||
Hyperf has some requirements for the system environment, it can only run under Linux and Mac environment, but due to the development of Docker virtualization technology, Docker for Windows can also be used as the running environment under Windows. | ||
|
||
The various versions of Dockerfile have been prepared for you in the [hyperf\hyperf-docker](https://github.com/hyperf/hyperf-docker) project, or directly based on the already built [hyperf\hyperf](https://hub.docker.com/r/hyperf/hyperf) Image to run. | ||
|
||
When you don't want to use Docker as the basis for your running environment, you need to make sure that your operating environment meets the following requirements: | ||
|
||
- PHP >= 7.2 | ||
- Swoole PHP extension >= 4.4,and Disabled `Short Name` | ||
- OpenSSL PHP extension | ||
- JSON PHP extension | ||
- PDO PHP extension (If you need to use MySQL Client) | ||
- Redis PHP extension (If you need to use Redis Client) | ||
- Protobuf PHP extension (If you need to use gRPC Server of Client) | ||
|
||
# Installation using Composer | ||
|
||
The easiest way to create a new Hyperf project is to use Composer. If you don't have it already installed, then please install as per the documentation. | ||
|
||
To create your new Hyperf project: | ||
|
||
$ composer create-project hyperf/hyperf-skeleton path/to/install | ||
|
||
Once installed, you can run the server immediately using the command below. | ||
|
||
$ cd path/to/install | ||
$ php bin/hyperf.php start | ||
|
||
This will start the cli-server on port `9501`, and bind it to all network interfaces. You can then visit the site at `http://localhost:9501/` | ||
|
||
which will bring up Hyperf default home page. |
Oops, something went wrong.