Skip to content

Commit 5e4b2a9

Browse files
committed
added fomo framework
1 parent f12751f commit 5e4b2a9

File tree

19 files changed

+656
-0
lines changed

19 files changed

+656
-0
lines changed

frameworks/PHP/fomo/.env

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
APP_NAME=Fomo
2+
APP_TIMEZONE=UTC
3+
APP_WORKER_COUNT=8
4+
APP_ENV=local
5+
APP_SSL=false
6+
APP_DEBUG=false
7+
APP_URL=http://localhost
8+
9+
DB_HOST=tfb-database
10+
DB_PORT=3306
11+
DB_DATABASE=hello_world
12+
DB_USERNAME=benchmarkdbuser
13+
DB_PASSWORD=benchmarkdbpass
14+
DB_CHARSET=utf8mb4
15+
DB_COLLATION=utf8mb4_unicode_ci
16+
17+
REDIS_HOST=127.0.0.1
18+
REDIS_PASSWORD=null
19+
REDIS_USERNAME=null
20+
REDIS_PORT=6379
21+
REDIS_DATABASE=0
22+

frameworks/PHP/fomo/.gitignore

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

frameworks/PHP/fomo/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
English | [中文](./README-CN.md)
2+
3+
[![Build Status](https://travis-ci.org/hyperf-cloud/hyperf.svg?branch=master)](https://travis-ci.org/hyperf-cloud/hyperf)
4+
[![Php Version](https://img.shields.io/badge/php-%3E=7.2-brightgreen.svg?maxAge=2592000)](https://secure.php.net/)
5+
[![Swoole Version](https://img.shields.io/badge/swoole-%3E=4.3.3-brightgreen.svg?maxAge=2592000)](https://github.com/swoole/swoole-src)
6+
[![Hyperf License](https://img.shields.io/github/license/hyperf-cloud/hyperf.svg?maxAge=2592000)](https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE.md)
7+
8+
# Introduction
9+
10+
Hyperf is a high-performance, highly flexible PHP CLI framework based on `Swoole 4.3+`. It has a built-in coroutine server with a large number of commonly used components. It provides ultra-high and better performance than the traditional PHP-FPM-based framework and also maintains extremely flexible scalability at the same time. Standard components are implemented in the latest PSR standards, and a powerful dependency injection design ensures that most components or classes within the framework are replaceable.
11+
12+
In addition to providing `MySQL coroutine client` and `Redis coroutine client`, common coroutine clients, the Hyperf component libraries are also prepared for the coroutine version of `Eloquent ORM`, `GRPC server and client`, `Zipkin (OpenTracing) client`, `Guzzle HTTP client`, `Elasticsearch client`, `Consul client`, `ETCD client`, `AMQP component`, `Apollo configuration center`, `Token bucket algorithm-based limiter`, and `Universal connection pool`, etc. Therefore, the trouble of implementing the corresponding coroutine version client by yourself can be avoided. Hyperf also provides convenient functions such as `Dependency injection`, `Annotation`, `AOP (aspect-oriented programming)`, `Middleware`, `Custom Processes`, `Event Manager`, `Simply Redis message queue`, and `Full-featured RabbitMQ message queue` to meet a wide range of technical and business scenarios.
13+
14+
# Original intention
15+
16+
Although there are many new PHP frameworks have been appeared, but we still has not seen a perfect framework which has the coexistence of elegant design and ultra-high performance, nor would we find a framework that really paves the way for PHP microservices. For the original intention of Hyperf and its team members, we will continue to invest to it, and you are welcome to join us to participate in open source construction.
17+
18+
# Design concept
19+
20+
`Hyperspeed + Flexibility = Hyperf`, from the framework name we have been used `hyperfspeed (ultra-high performance)` and `flexibility` as the gene of Hyperf.
21+
22+
For ultra-high performance, Hyperf based on the Swoole coroutine, it providered an amazing performance, Hyperf team also makes a lots of code optimizations on the framework design to ensure ultra-high performance.
23+
24+
For flexibility, based on the powerful dependency injection component of Hyperf, all components are based on [PSR](https://www.php-fig.org/psr) and the contracts that defined by Hyperf, so that most of the components or classes within the framework are replaceable and re-useable.
25+
26+
Based on the above characteristics, Hyperf has a lots of possibilities, such as implementing Web servers, gateway servers, distributed middleware software, microservices architecture, game servers, and Internet of Things (IoT).
27+
28+
# Documentation
29+
30+
[https://doc.hyperf.io/](https://doc.hyperf.io/)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace App\Exceptions;
4+
5+
use Fomo\Request\Request;
6+
use Throwable;
7+
8+
class Handler
9+
{
10+
public function notFoundHttpException(Request $request): string
11+
{
12+
return response()->json([
13+
'message' => 'not found'
14+
] , 404);
15+
}
16+
17+
public function notAllowedHttpException(Request $request): string
18+
{
19+
return response()->json([
20+
'message' => "this is route supported {$request->method()} method"
21+
] , 405);
22+
}
23+
24+
public function InternalErrorException(Request $request, Throwable $error): string
25+
{
26+
return response()->json([
27+
'message' => 'internal error'
28+
] , 500);
29+
}
30+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"framework": "fomo",
3+
"tests": [
4+
{
5+
"default": {
6+
"json_url": "/json",
7+
"plaintext_url": "/plaintext",
8+
"db_url": "/db",
9+
"fortune_url": "/fortunes",
10+
"query_url": "/query?queries=",
11+
"update_url": "/update?queries=",
12+
"port": 9000,
13+
"approach": "Realistic",
14+
"classification": "Micro",
15+
"database": "mysql",
16+
"framework": "Fomo",
17+
"language": "PHP",
18+
"flavor": "None",
19+
"orm": "Full",
20+
"platform": "swoole",
21+
"webserver": "None",
22+
"os": "Linux",
23+
"database_os": "Linux",
24+
"display_name": "Fomo",
25+
"notes": "",
26+
"versus": "swoole"
27+
}
28+
}
29+
]
30+
}
31+

frameworks/PHP/fomo/composer.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "fomo/fomo",
3+
"description": "The Fomo Framework",
4+
"keywords": ["framework", "fomo" , "high performance"],
5+
"type": "project",
6+
"license": "MIT",
7+
"authors": [
8+
{
9+
"name": "Amir",
10+
"email": "[email protected]"
11+
}
12+
],
13+
"require": {
14+
"php" : ">=8.1",
15+
"fomo/framework": "^2.0"
16+
},
17+
"autoload": {
18+
"psr-4": {
19+
"App\\" : "app/" ,
20+
"Database\\" : "database/",
21+
"Storage\\Routes\\" : "storage/routes/"
22+
}
23+
},
24+
"autoload-dev": {
25+
"psr-4": {
26+
"Tests\\": "tests/"
27+
}
28+
},
29+
"scripts": {
30+
"post-root-package-install": [
31+
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
32+
]
33+
},
34+
"minimum-stability": "dev",
35+
"prefer-stable": true,
36+
"require-dev": {
37+
"fakerphp/faker": "^1.15",
38+
"phpunit/phpunit": "^9.5"
39+
},
40+
"config": {
41+
"allow-plugins": {
42+
"php-http/discovery": true
43+
}
44+
}
45+
}

frameworks/PHP/fomo/config.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[framework]
2+
name = "fomo"
3+
4+
[main]
5+
urls.plaintext = "/plaintext"
6+
urls.json = "/json"
7+
urls.db = "/db"
8+
urls.query = "/queries/"
9+
urls.update = "/updates/"
10+
urls.fortune = "/fortunes"
11+
approach = "Realistic"
12+
classification = "Fullstack"
13+
database = "MySQL"
14+
database_os = "Linux"
15+
os = "Linux"
16+
orm = "Full"
17+
platform = "swoole"
18+
webserver = "None"
19+
versus = "swoole"

frameworks/PHP/fomo/config/app.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
return [
4+
'name' => env('APP_NAME' , 'Fomo'),
5+
'timezone' => env('APP_TIMEZONE' , 'UTC'),
6+
'faker_locale' => 'en_US' ,
7+
'locale' => 'en' ,
8+
];
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
return [
4+
'default' => env('DB_CONNECTION', 'mysql'),
5+
6+
'connections' => [
7+
8+
'sqlite' => [
9+
'driver' => 'sqlite',
10+
'url' => env('DATABASE_URL'),
11+
'database' => env('DB_DATABASE', databasePath('database.sqlite')),
12+
'prefix' => '',
13+
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
14+
],
15+
16+
'mysql' => [
17+
'driver' => 'mysql',
18+
'url' => env('DATABASE_URL'),
19+
'host' => env('DB_HOST', '127.0.0.1'),
20+
'port' => env('DB_PORT', '3306'),
21+
'database' => env('DB_DATABASE', 'forge'),
22+
'username' => env('DB_USERNAME', 'forge'),
23+
'password' => env('DB_PASSWORD', ''),
24+
'unix_socket' => env('DB_SOCKET', ''),
25+
'charset' => 'utf8mb4',
26+
'collation' => 'utf8mb4_unicode_ci',
27+
'prefix' => '',
28+
'prefix_indexes' => true,
29+
'strict' => true,
30+
'engine' => null,
31+
'options' => extension_loaded('pdo_mysql') ? array_filter([
32+
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
33+
]) : [],
34+
],
35+
36+
'pgsql' => [
37+
'driver' => 'pgsql',
38+
'url' => env('DATABASE_URL'),
39+
'host' => env('DB_HOST', '127.0.0.1'),
40+
'port' => env('DB_PORT', '5432'),
41+
'database' => env('DB_DATABASE', 'forge'),
42+
'username' => env('DB_USERNAME', 'forge'),
43+
'password' => env('DB_PASSWORD', ''),
44+
'charset' => 'utf8',
45+
'prefix' => '',
46+
'prefix_indexes' => true,
47+
'search_path' => 'public',
48+
'sslmode' => 'prefer',
49+
],
50+
51+
'sqlsrv' => [
52+
'driver' => 'sqlsrv',
53+
'url' => env('DATABASE_URL'),
54+
'host' => env('DB_HOST', 'localhost'),
55+
'port' => env('DB_PORT', '1433'),
56+
'database' => env('DB_DATABASE', 'forge'),
57+
'username' => env('DB_USERNAME', 'forge'),
58+
'password' => env('DB_PASSWORD', ''),
59+
'charset' => 'utf8',
60+
'prefix' => '',
61+
'prefix_indexes' => true,
62+
// 'encrypt' => env('DB_ENCRYPT', 'yes'),
63+
// 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'),
64+
],
65+
66+
]
67+
];
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
return [
4+
'host' => env('ELASTICSEARCH_HOST' , '127.0.0.1'),
5+
'port' => env('ELASTICSEARCH_PORT' , 9200),
6+
'username' => env('ELASTICSEARCH_USERNAME'),
7+
'password' => env('ELASTICSEARCH_PASSWORD')
8+
];

0 commit comments

Comments
 (0)