Skip to content

Commit b64c714

Browse files
authored
Merge pull request #502 from utopia-php/chore-revert-framework-v2
Chore revert framework v2
2 parents 53c4ff7 + 1f4b7df commit b64c714

61 files changed

Lines changed: 8494 additions & 3548 deletions

Some content is hidden

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

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ jobs:
7777
Postgres,
7878
SQLite,
7979
MongoDB,
80+
Mirror,
8081
SharedTables/MariaDB,
8182
SharedTables/MySQL,
8283
SharedTables/Postgres,

Dockerfile

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,39 @@
11
FROM composer:2.0 AS composer
22

3-
ARG TESTING=false
4-
ENV TESTING=$TESTING
5-
63
WORKDIR /usr/local/src/
74

85
COPY composer.lock /usr/local/src/
96
COPY composer.json /usr/local/src/
107

11-
RUN composer install --ignore-platform-reqs --optimize-autoloader \
12-
--no-plugins --no-scripts --prefer-dist
13-
14-
FROM php:8.3.3-cli-alpine3.19 AS compile
8+
RUN composer install \
9+
--ignore-platform-reqs \
10+
--optimize-autoloader \
11+
--no-plugins \
12+
--no-scripts \
13+
--prefer-dist
14+
15+
FROM php:8.3.10-cli-alpine3.20 AS compile
1516

16-
ENV PHP_REDIS_VERSION=6.0.2 \
17-
PHP_SWOOLE_VERSION=v5.1.2 \
18-
PHP_MONGO_VERSION=1.16.1 \
19-
PHP_XDEBUG_VERSION=3.3.2
17+
ENV PHP_REDIS_VERSION="6.0.2" \
18+
PHP_SWOOLE_VERSION="v5.1.3" \
19+
PHP_MONGO_VERSION="1.16.1" \
20+
PHP_XDEBUG_VERSION="3.3.2"
2021

2122
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
2223

2324
RUN \
2425
apk update \
25-
&& apk add --no-cache postgresql-libs postgresql-dev make automake autoconf gcc g++ git brotli-dev linux-headers \
26+
&& apk add --no-cache \
27+
postgresql-libs \
28+
postgresql-dev \
29+
make \
30+
automake \
31+
autoconf \
32+
gcc \
33+
g++ \
34+
git \
35+
brotli-dev \
36+
linux-headers \
2637
&& docker-php-ext-install opcache pgsql pdo_mysql pdo_pgsql \
2738
&& apk del postgresql-dev \
2839
&& rm -rf /var/cache/apk/*
@@ -86,6 +97,7 @@ RUN echo extension=redis.so >> /usr/local/etc/php/conf.d/redis.ini
8697
RUN echo extension=swoole.so >> /usr/local/etc/php/conf.d/swoole.ini
8798
RUN echo extension=mongodb.so >> /usr/local/etc/php/conf.d/mongodb.ini
8899
RUN echo extension=pcov.so >> /usr/local/etc/php/conf.d/pcov.ini
100+
RUN echo extension=xdebug.so >> /usr/local/etc/php/conf.d/xdebug.ini
89101

90102
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
91103

@@ -100,14 +112,13 @@ COPY --from=mongodb /usr/local/lib/php/extensions/no-debug-non-zts-20230831/mong
100112
COPY --from=pcov /usr/local/lib/php/extensions/no-debug-non-zts-20230831/pcov.so /usr/local/lib/php/extensions/no-debug-non-zts-20230831/
101113
COPY --from=xdebug /usr/local/lib/php/extensions/no-debug-non-zts-20230831/xdebug.so /usr/local/lib/php/extensions/no-debug-non-zts-20230831/
102114

103-
# Add Source Code
104115
COPY ./bin /usr/src/code/bin
105116
COPY ./src /usr/src/code/src
106117
COPY ./dev /usr/src/code/dev
107118

108119
# Add Debug Configs
109-
RUN if [ "$DEBUG" == "true" ]; then cp /usr/src/code/dev/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini; fi
110-
RUN if [ "$DEBUG" == "true" ]; then mkdir -p /tmp/xdebug; fi
120+
RUN if [ "$DEBUG" = "true" ]; then cp /usr/src/code/dev/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini; fi
121+
RUN if [ "$DEBUG" = "true" ]; then mkdir -p /tmp/xdebug; fi
111122
RUN if [ "$DEBUG" = "false" ]; then rm -rf /usr/src/code/dev; fi
112123
RUN if [ "$DEBUG" = "false" ]; then rm -f /usr/local/lib/php/extensions/no-debug-non-zts-20220829/xdebug.so; fi
113124

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ A list of the utopia/php concepts and their relevant equivalent using the differ
2626
- **Document** - A simple JSON object that will be stored in one of the utopia/database collections. For SQL-based adapters, this will be equivalent to a row. For a No-SQL adapter, this will equivalent to a native document.
2727
- **Attribute** - A simple document attribute. For SQL-based adapters, this will be equivalent to a column. For a No-SQL adapter, this will equivalent to a native document field.
2828
- **Index** - A simple collection index used to improve the performance of your database queries.
29-
- **Permissions** - Using permissions, you can decide which roles have read, create, update and delete access for a specific document. The special attribute `$permissions` is used to store permission metadata for each document in the collection. A permission role can be any string you want. You can use `$authorization->addRole()` to delegate new roles to your users, once obtained a new role a user would gain read, create, update or delete access to a relevant document.
29+
- **Permissions** - Using permissions, you can decide which roles have read, create, update and delete access for a specific document. The special attribute `$permissions` is used to store permission metadata for each document in the collection. A permission role can be any string you want. You can use `Authorization::setRole()` to delegate new roles to your users, once obtained a new role a user would gain read, create, update or delete access to a relevant document.
3030

3131
### Filters
3232

bin/tasks/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
use Utopia\Database\Adapter\Mongo;
1414
use Utopia\Database\Adapter\MySQL;
1515
use Utopia\Database\Database;
16-
use Utopia\Http\Validator\Text;
1716
use Utopia\Mongo\Client;
17+
use Utopia\Validator\Text;
1818

1919
/**
2020
* @Example

bin/tasks/load.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@
2121
use Utopia\Database\Helpers\Permission;
2222
use Utopia\Database\Helpers\Role;
2323
use Utopia\Database\Validator\Authorization;
24-
use Utopia\Http\Validator\Numeric;
25-
use Utopia\Http\Validator\Text;
2624
use Utopia\Mongo\Client;
27-
28-
$authorization = new Authorization();
25+
use Utopia\Validator\Numeric;
26+
use Utopia\Validator\Text;
2927

3028
/**
3129
* @Example
@@ -63,7 +61,7 @@
6361
$database->setNamespace($namespace);
6462

6563
// Outline collection schema
66-
$createSchema($database);
64+
createSchema($database);
6765

6866
// reclaim resources
6967
$database = null;
@@ -123,7 +121,7 @@
123121
$database->setNamespace($namespace);
124122

125123
// Outline collection schema
126-
$createSchema($database);
124+
createSchema($database);
127125

128126
// reclaim resources
129127
$database = null;
@@ -185,7 +183,7 @@
185183
$database->setNamespace($namespace);
186184

187185
// Outline collection schema
188-
$createSchema($database);
186+
createSchema($database);
189187

190188
// Fill DB
191189
$faker = Factory::create();
@@ -228,13 +226,14 @@
228226
});
229227

230228

231-
$createSchema = function (Database $database) use ($authorization): void {
229+
function createSchema(Database $database): void
230+
{
232231
if ($database->exists($database->getDatabase())) {
233232
$database->delete($database->getDatabase());
234233
}
235234
$database->create();
236235

237-
$authorization->addRole(Role::any()->toString());
236+
Authorization::setRole(Role::any()->toString());
238237

239238
$database->createCollection('articles', permissions: [
240239
Permission::create(Role::any()),
@@ -248,7 +247,7 @@
248247
$database->createAttribute('articles', 'views', Database::VAR_INTEGER, 0, true);
249248
$database->createAttribute('articles', 'tags', Database::VAR_STRING, 0, true, array: true);
250249
$database->createIndex('articles', 'text', Database::INDEX_FULLTEXT, ['text']);
251-
};
250+
}
252251

253252
function createDocument($database, Generator $faker): void
254253
{

bin/tasks/query.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
use Utopia\Database\Adapter\MySQL;
1515
use Utopia\Database\Database;
1616
use Utopia\Database\Query;
17-
use Utopia\Http\Validator\Numeric;
18-
use Utopia\Http\Validator\Text;
17+
use Utopia\Database\Validator\Authorization;
1918
use Utopia\Mongo\Client;
19+
use Utopia\Validator\Numeric;
20+
use Utopia\Validator\Text;
2021

2122
/**
2223
* @Example
@@ -83,35 +84,35 @@
8384

8485
$report = [];
8586

86-
$count = $setRoles($faker, 1);
87+
$count = setRoles($faker, 1);
8788
Console::info("\n{$count} roles:");
8889
$report[] = [
8990
'roles' => $count,
9091
'results' => runQueries($database, $limit)
9192
];
9293

93-
$count = $setRoles($faker, 100);
94+
$count = setRoles($faker, 100);
9495
Console::info("\n{$count} roles:");
9596
$report[] = [
9697
'roles' => $count,
9798
'results' => runQueries($database, $limit)
9899
];
99100

100-
$count = $setRoles($faker, 400);
101+
$count = setRoles($faker, 400);
101102
Console::info("\n{$count} roles:");
102103
$report[] = [
103104
'roles' => $count,
104105
'results' => runQueries($database, $limit)
105106
];
106107

107-
$count = $setRoles($faker, 500);
108+
$count = setRoles($faker, 500);
108109
Console::info("\n{$count} roles:");
109110
$report[] = [
110111
'roles' => $count,
111112
'results' => runQueries($database, $limit)
112113
];
113114

114-
$count = $setRoles($faker, 1000);
115+
$count = setRoles($faker, 1000);
115116
Console::info("\n{$count} roles:");
116117
$report[] = [
117118
'roles' => $count,
@@ -135,12 +136,13 @@
135136
Console::error($error->getMessage());
136137
});
137138

138-
$setRoles = function ($faker, $count) use ($authorization): int {
139+
function setRoles($faker, $count): int
140+
{
139141
for ($i = 0; $i < $count; $i++) {
140-
$authorization->addRole($faker->numerify('user####'));
142+
Authorization::setRole($faker->numerify('user####'));
141143
}
142-
return \count($authorization->getRoles());
143-
};
144+
return \count(Authorization::getRoles());
145+
}
144146

145147
function runQueries(Database $database, int $limit): array
146148
{

composer.json

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,39 @@
2727
"Composer\\Config::disableProcessTimeout",
2828
"docker compose exec tests vendor/bin/phpunit --configuration phpunit.xml"
2929
],
30-
"lint": "./vendor/bin/pint --test",
31-
"format": "./vendor/bin/pint",
30+
"lint": "php -d memory_limit=2G ./vendor/bin/pint --test",
31+
"format": "php -d memory_limit=2G ./vendor/bin/pint",
3232
"check": "./vendor/bin/phpstan analyse --level 7 src tests --memory-limit 2G",
3333
"coverage": "./vendor/bin/coverage-check ./tmp/clover.xml 90"
3434
},
3535
"require": {
36+
"php": ">=8.3",
3637
"ext-pdo": "*",
3738
"ext-mbstring": "*",
38-
"php": ">=8.0",
39-
"utopia-php/framework": "1.0.*",
40-
"utopia-php/cache": "0.10.*",
39+
"utopia-php/framework": "0.33.*",
40+
"utopia-php/cache": "0.11.*",
4141
"utopia-php/mongo": "0.3.*"
4242
},
4343
"require-dev": {
4444
"fakerphp/faker": "1.23.*",
45-
"phpunit/phpunit": "9.6.*",
46-
"pcov/clobber": "2.0.*",
45+
"phpunit/phpunit": "9.*",
46+
"pcov/clobber": "2.*",
4747
"swoole/ide-helper": "5.1.3",
48-
"utopia-php/cli": "0.19.*",
49-
"laravel/pint": "1.17.*",
50-
"phpstan/phpstan": "1.11.*",
48+
"utopia-php/cli": "0.14.*",
49+
"laravel/pint": "1.*",
50+
"phpstan/phpstan": "1.*",
5151
"rregeer/phpunit-coverage-check": "0.3.*"
5252
},
5353
"suggests": {
5454
"ext-mongodb": "Needed to support MongoDB Database Adapter",
5555
"ext-redis": "Needed to support Redis Cache Adapter",
5656
"ext-pdo": "Needed to support MariaDB, MySQL or SQLite Database Adapter",
5757
"mongodb/mongodb": "Needed to support MongoDB Database Adapter"
58+
},
59+
"config": {
60+
"allow-plugins": {
61+
"php-http/discovery": true,
62+
"tbachert/spi": true
63+
}
5864
}
5965
}

0 commit comments

Comments
 (0)