Skip to content

Commit 756600e

Browse files
n0nag0njoanhey
andauthored
Fomo framework for PHP (#9584)
* added fomo framework * added some .keep files * corrected readme * Update .env remove APP_WORKER_COUNT * Test with PHP8.4 * Revert to PHP8.3 Work but with deprecated errrors. * Remove unnece * Remove unnecessary services configs --------- Co-authored-by: Joan Miquel <[email protected]>
1 parent cb99cc7 commit 756600e

File tree

18 files changed

+622
-0
lines changed

18 files changed

+622
-0
lines changed

frameworks/PHP/fomo/.env

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

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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Introduction
2+
3+
Fomo is a web application framework based.
4+
5+
We tried to implement Fomo in the simplest possible way so that anyone can use it.
6+
7+
Fomo supports the following:
8+
9+
- Simple, fast routing engine.
10+
- Processing work in the background.
11+
- Queued job processing.
12+
- And more...
13+
14+
Fomo is very fast, simple and for use in large scale projects.
15+
16+
# Original intention
17+
18+
Here's 3 reason why you should use Fomo:
19+
20+
- Fomo is very simple (less to learn and train others on).
21+
- Fomo is very fast (uses fewer resources to do the same thing).
22+
- Fomo is another tool that developers can use to solve their complex problems in a simple way.
23+
24+
# Documentation
25+
26+
[https://fomo-framework.github.io/docs/](https://fomo-framework.github.io/docs/)
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+
];

frameworks/PHP/fomo/config/server.php

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
3+
return [
4+
/*
5+
* mode
6+
* SWOOLE_BASE ,
7+
* SWOOLE_PROCESS
8+
*/
9+
'mode' => SWOOLE_BASE ,
10+
'host' => '0.0.0.0',
11+
'port' => 9000 ,
12+
'sockType' => SWOOLE_SOCK_TCP ,
13+
'additional' => [
14+
'worker_num' => env('APP_WORKER_COUNT' , cpuCount() * 2) ,
15+
/*
16+
* log level
17+
* SWOOLE_LOG_DEBUG (default)
18+
* SWOOLE_LOG_TRACE
19+
* SWOOLE_LOG_INFO
20+
* SWOOLE_LOG_NOTICE
21+
* SWOOLE_LOG_WARNING
22+
* SWOOLE_LOG_ERROR
23+
*/
24+
'log_level' => SWOOLE_LOG_DEBUG ,
25+
'log_file' => storagePath('logs/fomo.log') ,
26+
27+
/*
28+
This key causes Fomo to receive a complete HTTP data packet and prevents it from receiving incomplete HTTP packets.
29+
*/
30+
'open_http_protocol' => true,
31+
],
32+
33+
'ssl' => [
34+
'ssl_cert_file' => null ,
35+
'ssl_key_file' => null ,
36+
] ,
37+
38+
/*
39+
* The following services are created for better performance in the program, only one object is created from them and they can be used throughout the program
40+
*/
41+
'services' => [
42+
Fomo\Services\Cache::class ,
43+
Fomo\Services\Database::class ,
44+
Fomo\Services\Language::class ,
45+
Fomo\Services\Response::class ,
46+
Fomo\Services\Validation::class ,
47+
] ,
48+
49+
/*
50+
* Files and folders that must be changed in real time
51+
*/
52+
'watcher' => [
53+
'app',
54+
'config',
55+
'database',
56+
'language',
57+
'routes',
58+
'composer.lock',
59+
'.env',
60+
] ,
61+
62+
/*
63+
* Each of the following causes changes to the performance of the desired class. (so be careful in using them)
64+
*/
65+
'advanceMode' => [
66+
/*
67+
* advanced mode in Fomo\Request\Request class
68+
*
69+
* By activating the advanced mode in this class, you can access the data you want in an advanced way
70+
* For example, consider that the user has sent you a array of the information of several customers.
71+
* If the advanced mode is not active, you can only access an array of all customer information
72+
*
73+
* For example, the:
74+
* $request->get('customers')
75+
*
76+
* But if the advanced mode is active, you can access any data you need from customers
77+
* For example, the:
78+
* $request->get('customers.*.name')
79+
*/
80+
'request' => DISABLE
81+
]
82+
];

0 commit comments

Comments
 (0)