Skip to content

Commit 380c3eb

Browse files
author
chenchangqin
committed
develop#项目文件
1 parent f0e39ee commit 380c3eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1245
-3
lines changed

.idea/php.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hyperf/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

hyperf/Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,12 @@ RUN set -ex \
4747
&& rm -rf /var/cache/apk/* /tmp/* /usr/share/man \
4848
&& echo -e "\033[42;37m Build Completed :).\033[0m\n"
4949

50-
EXPOSE 9501
50+
COPY hyperf-skeleton /hyperf-skeleton
51+
52+
WORKDIR /hyperf-skeleton
53+
54+
RUN rm -rf /hyperf-skeleton/runtime/container/proxy
55+
56+
EXPOSE 9501
57+
58+
ENTRYPOINT ["php", "/hyperf-skeleton/bin/hyperf.php", "start"]

hyperf/hyperf-skeleton/.env.example

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
APP_NAME=skeleton
2+
APP_ENV=dev
3+
4+
DB_DRIVER=mysql
5+
DB_HOST=localhost
6+
DB_PORT=3306
7+
DB_DATABASE=hyperf
8+
DB_USERNAME=root
9+
DB_PASSWORD=
10+
DB_CHARSET=utf8mb4
11+
DB_COLLATION=utf8mb4_unicode_ci
12+
DB_PREFIX=
13+
14+
REDIS_HOST=localhost
15+
REDIS_AUTH=(null)
16+
REDIS_PORT=6379
17+
REDIS_DB=0

hyperf/hyperf-skeleton/.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.buildpath
2+
.settings/
3+
.project
4+
*.patch
5+
.idea/
6+
.git/
7+
runtime/
8+
vendor/
9+
.phpintel/
10+
.env
11+
.DS_Store
12+
*.lock
13+
.phpunit*

hyperf/hyperf-skeleton/.gitlab-ci.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# usermod -aG docker gitlab-runner
2+
3+
stages:
4+
- build
5+
- deploy
6+
7+
variables:
8+
PROJECT_NAME: hyperf
9+
REGISTRY_URL: registry-docker.org
10+
11+
build_test_docker:
12+
stage: build
13+
before_script:
14+
# - git submodule sync --recursive
15+
# - git submodule update --init --recursive
16+
script:
17+
- docker build . -t $PROJECT_NAME
18+
- docker tag $PROJECT_NAME $REGISTRY_URL/$PROJECT_NAME:test
19+
- docker push $REGISTRY_URL/$PROJECT_NAME:test
20+
only:
21+
- test
22+
tags:
23+
- builder
24+
25+
deploy_test_docker:
26+
stage: deploy
27+
script:
28+
- docker stack deploy -c deploy.test.yml --with-registry-auth $PROJECT_NAME
29+
only:
30+
- test
31+
tags:
32+
- test
33+
34+
build_docker:
35+
stage: build
36+
before_script:
37+
# - git submodule sync --recursive
38+
# - git submodule update --init --recursive
39+
script:
40+
- docker build . -t $PROJECT_NAME
41+
- docker tag $PROJECT_NAME $REGISTRY_URL/$PROJECT_NAME:$CI_COMMIT_REF_NAME
42+
- docker tag $PROJECT_NAME $REGISTRY_URL/$PROJECT_NAME:latest
43+
- docker push $REGISTRY_URL/$PROJECT_NAME:$CI_COMMIT_REF_NAME
44+
- docker push $REGISTRY_URL/$PROJECT_NAME:latest
45+
only:
46+
- tags
47+
tags:
48+
- builder
49+
50+
deploy_docker:
51+
stage: deploy
52+
script:
53+
- echo SUCCESS
54+
only:
55+
- tags
56+
tags:
57+
- builder

hyperf/hyperf-skeleton/.php_cs

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?php
2+
3+
$header = <<<'EOF'
4+
This file is part of Hyperf.
5+
6+
@link https://www.hyperf.io
7+
@document https://doc.hyperf.io
8+
@contact group@hyperf.io
9+
@license https://github.com/hyperf/hyperf/blob/master/LICENSE
10+
EOF;
11+
12+
return PhpCsFixer\Config::create()
13+
->setRiskyAllowed(true)
14+
->setRules([
15+
'@PSR2' => true,
16+
'@Symfony' => true,
17+
'@DoctrineAnnotation' => true,
18+
'@PhpCsFixer' => true,
19+
'header_comment' => [
20+
'commentType' => 'PHPDoc',
21+
'header' => $header,
22+
'separate' => 'none',
23+
'location' => 'after_declare_strict',
24+
],
25+
'array_syntax' => [
26+
'syntax' => 'short'
27+
],
28+
'list_syntax' => [
29+
'syntax' => 'short'
30+
],
31+
'concat_space' => [
32+
'spacing' => 'one'
33+
],
34+
'blank_line_before_statement' => [
35+
'statements' => [
36+
'declare',
37+
],
38+
],
39+
'general_phpdoc_annotation_remove' => [
40+
'annotations' => [
41+
'author'
42+
],
43+
],
44+
'ordered_imports' => [
45+
'imports_order' => [
46+
'class', 'function', 'const',
47+
],
48+
'sort_algorithm' => 'alpha',
49+
],
50+
'single_line_comment_style' => [
51+
'comment_types' => [
52+
],
53+
],
54+
'yoda_style' => [
55+
'always_move_variable' => false,
56+
'equal' => false,
57+
'identical' => false,
58+
],
59+
'phpdoc_align' => [
60+
'align' => 'left',
61+
],
62+
'multiline_whitespace_before_semicolons' => [
63+
'strategy' => 'no_multi_line',
64+
],
65+
'constant_case' => [
66+
'case' => 'lower',
67+
],
68+
'class_attributes_separation' => true,
69+
'combine_consecutive_unsets' => true,
70+
'declare_strict_types' => true,
71+
'linebreak_after_opening_tag' => true,
72+
'lowercase_static_reference' => true,
73+
'no_useless_else' => true,
74+
'no_unused_imports' => true,
75+
'not_operator_with_successor_space' => true,
76+
'not_operator_with_space' => false,
77+
'ordered_class_elements' => true,
78+
'php_unit_strict' => false,
79+
'phpdoc_separation' => false,
80+
'single_quote' => true,
81+
'standardize_not_equals' => true,
82+
'multiline_comment_opening_closing' => true,
83+
])
84+
->setFinder(
85+
PhpCsFixer\Finder::create()
86+
->exclude('public')
87+
->exclude('runtime')
88+
->exclude('vendor')
89+
->in(__DIR__)
90+
)
91+
->setUsingCache(false);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace PHPSTORM_META {
4+
5+
// Reflect
6+
override(\Psr\Container\ContainerInterface::get(0), map('@'));
7+
override(\Hyperf\Utils\Context::get(0), map('@'));
8+
override(\make(0), map('@'));
9+
override(\di(0), map('@'));
10+
11+
}

hyperf/hyperf-skeleton/Dockerfile

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Default Dockerfile
2+
#
3+
# @link https://www.hyperf.io
4+
# @document https://doc.hyperf.io
5+
# @contact group@hyperf.io
6+
# @license https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
7+
8+
FROM hyperf/hyperf:7.2-alpine-v3.9-cli
9+
LABEL maintainer="Hyperf Developers <group@hyperf.io>" version="1.0" license="MIT" app.name="Hyperf"
10+
11+
##
12+
# ---------- env settings ----------
13+
##
14+
# --build-arg timezone=Asia/Shanghai
15+
ARG timezone
16+
17+
ENV TIMEZONE=${timezone:-"Asia/Shanghai"} \
18+
COMPOSER_VERSION=1.9.1 \
19+
APP_ENV=prod \
20+
SCAN_CACHEABLE=(true)
21+
22+
# update
23+
RUN set -ex \
24+
&& apk update \
25+
# install composer
26+
&& cd /tmp \
27+
&& wget https://github.com/composer/composer/releases/download/${COMPOSER_VERSION}/composer.phar \
28+
&& chmod u+x composer.phar \
29+
&& mv composer.phar /usr/local/bin/composer \
30+
# show php version and extensions
31+
&& php -v \
32+
&& php -m \
33+
&& php --ri swoole \
34+
# ---------- some config ----------
35+
&& cd /etc/php7 \
36+
# - config PHP
37+
&& { \
38+
echo "upload_max_filesize=100M"; \
39+
echo "post_max_size=108M"; \
40+
echo "memory_limit=1024M"; \
41+
echo "date.timezone=${TIMEZONE}"; \
42+
} | tee conf.d/99_overrides.ini \
43+
# - config timezone
44+
&& ln -sf /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \
45+
&& echo "${TIMEZONE}" > /etc/timezone \
46+
# ---------- clear works ----------
47+
&& rm -rf /var/cache/apk/* /tmp/* /usr/share/man \
48+
&& echo -e "\033[42;37m Build Completed :).\033[0m\n"
49+
50+
WORKDIR /opt/www
51+
52+
# Composer Cache
53+
# COPY ./composer.* /opt/www/
54+
# RUN composer install --no-dev --no-scripts
55+
56+
COPY . /opt/www
57+
RUN composer install --no-dev -o && php bin/hyperf.php
58+
59+
EXPOSE 9501
60+
61+
ENTRYPOINT ["php", "/opt/www/bin/hyperf.php", "start"]

hyperf/hyperf-skeleton/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Introduction
2+
3+
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.
4+
5+
# Requirements
6+
7+
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.
8+
9+
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.
10+
11+
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:
12+
13+
- PHP >= 7.2
14+
- Swoole PHP extension >= 4.4,and Disabled `Short Name`
15+
- OpenSSL PHP extension
16+
- JSON PHP extension
17+
- PDO PHP extension (If you need to use MySQL Client)
18+
- Redis PHP extension (If you need to use Redis Client)
19+
- Protobuf PHP extension (If you need to use gRPC Server of Client)
20+
21+
# Installation using Composer
22+
23+
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.
24+
25+
To create your new Hyperf project:
26+
27+
$ composer create-project hyperf/hyperf-skeleton path/to/install
28+
29+
Once installed, you can run the server immediately using the command below.
30+
31+
$ cd path/to/install
32+
$ php bin/hyperf.php start
33+
34+
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/`
35+
36+
which will bring up Hyperf default home page.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* This file is part of Hyperf.
6+
*
7+
* @link https://www.hyperf.io
8+
* @document https://doc.hyperf.io
9+
* @contact group@hyperf.io
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+
*/
12+
namespace App\Constants;
13+
14+
use Hyperf\Constants\AbstractConstants;
15+
use Hyperf\Constants\Annotation\Constants;
16+
17+
/**
18+
* @Constants
19+
*/
20+
class ErrorCode extends AbstractConstants
21+
{
22+
/**
23+
* @Message("Server Error!")
24+
*/
25+
const SERVER_ERROR = 500;
26+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* This file is part of Hyperf.
6+
*
7+
* @link https://www.hyperf.io
8+
* @document https://doc.hyperf.io
9+
* @contact group@hyperf.io
10+
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
11+
*/
12+
namespace App\Controller;
13+
14+
use Hyperf\Di\Annotation\Inject;
15+
use Hyperf\HttpServer\Contract\RequestInterface;
16+
use Hyperf\HttpServer\Contract\ResponseInterface;
17+
use Psr\Container\ContainerInterface;
18+
19+
abstract class AbstractController
20+
{
21+
/**
22+
* @Inject
23+
* @var ContainerInterface
24+
*/
25+
protected $container;
26+
27+
/**
28+
* @Inject
29+
* @var RequestInterface
30+
*/
31+
protected $request;
32+
33+
/**
34+
* @Inject
35+
* @var ResponseInterface
36+
*/
37+
protected $response;
38+
}

0 commit comments

Comments
 (0)