Skip to content

Commit f7c19fa

Browse files
alanpoulaindunglas
authored andcommitted
MongoDB support (#2144)
* Add mongodb ItemProvider * Fix pagination extension * FIx propertymetadatafactory * Fix query extension compiler pass * #460 Fix fatal error: 'phpDocumentor\Reflection\DocBlockFactory' not found * Small fixes * Remove @todo * Refactor bundle configuration * Add mongodb filter and abstraction * Add mongodb filter extension * Fix ItemDataProvider using only one id Remove idea * Apply StyleCI patch file * Declare variable in AbstractFilter to fix Scrutinizer warning * Add missing AbstractFilter namespace * Change DataProviderInterface's namespace to use new DataProvider location * Tag mongodb data providers * Remove old dataprovider definitions from doctrine_mongodb.xml * Use correct PaginatorInterface namespace * hotfix: add mongodb to ci && fix unit test * add composer.json * ignore platform reqs * ignore platform reqs * - add behat on mongo - add symfony mongo test - add mongo on travis & appveyor * - add behat on mongo - add symfony mongo test - add mongo on travis & appveyor * Merge branch 'odm-support' of https://github.com/samvdb/DunglasApiBundle into samvdb-odm-support # Conflicts: # appveyor.yml # composer.json # src/Bridge/Doctrine/Filter/AbstractFilter.php # src/Bridge/Symfony/Bundle/DependencyInjection/Compiler/DoctrineQueryExtensionPass.php # src/Bridge/Symfony/Bundle/DependencyInjection/Configuration.php # tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php # tests/Bridge/Symfony/Bundle/DependencyInjection/Compiler/DoctrineQueryExtensionPassTest.php # tests/Bridge/Symfony/Bundle/DependencyInjection/ConfigurationTest.php * Fix phpunit and behat tests * Mongodb behat tests first step * Fix tests * Refactoring of the filters and working boolean filter * Use PropertyHelper and working search filter * Changes for PropertyHelper * Private and final * Use trait instead of service for propertyHelper * Add date filter * Add exists filter * Uniformize filters * Fix autowiring in ApiFilter compiler pass for MongoDB filters * Add numeric filter and remove references of DBAL in Common * Add order filter * Add range filter and fix some tests * Fix some tests * Subresources management and better interfaces * Fix lookups and pagination * Add DoctrineEctractor for MongoDB * Fix some tests and item data provider * Fix more tests (fos-user) * More tests * Fix more tests * Add OrderExtension and fix tests * Fix more tests and fix the paginator * Fix last Behat tests + use context as reference to solve sort issue + some cleaning * Fix some CS * Fix exists filter unit test * Replace MongoDB with MongoDbOdm * Fix last unit test * Add a unit test for the boolean filter * Add a unit test for the date filter * Unit tests for exists filter * Unit tests for numerci filter * Unit tests for order filter * Remove unused tags * Unit tests for range and search filters * Fix MongoDB CustomActionController * Add unit tests for extensions * Unit tests for PropertyMetadataFactory * Tests for DoctrineExtractor * Fix CS + test * Add unit test for CollectionDataProvider * Add unit tests for ItemDataProvider and move IdentifierManagerTrait to Common * Fixes in Paginator and unit tests for it * Add subresource unit tests * Fix @vincentchalamon reported issue * Fix CS * Use MongoDB ODM 2.0 * Add no-api to repositories * Fix paginator * Fix phpstan * Traits more usable and add experimental annotation * Better handling of configuration * Fix PHP 7.1 * Fix providers issue when item is not found * Fix relation issues and HAL normalizer * Fix phpunit vendor failure * Allow nested lookups * Fix tests and CS * Ensure BC in AbstractFilter * CS * Fix broken test * Fix routing * Fix alcaeus' comments * Fix the pagination * Minor fixes * Add tests for date filter and simplify code
1 parent 3405a42 commit f7c19fa

File tree

234 files changed

+18721
-2970
lines changed

Some content is hidden

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

234 files changed

+18721
-2970
lines changed

.circleci/config.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ reusable-steps:
1313
run:
1414
name: Disable Xdebug PHP extension
1515
command: sudo rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
16+
- &install-php-extensions
17+
run:
18+
name: Install PHP extensions
19+
command: |
20+
sudo pecl install mongodb
21+
echo 'extension=mongodb.so' | sudo tee /usr/local/etc/php/conf.d/mongodb.ini
1622
- &restore-composer-cache
1723
restore_cache:
1824
keys:
@@ -106,6 +112,7 @@ jobs:
106112
- *restore-composer-cache
107113
- *disable-xdebug-php-extension
108114
- *disable-php-memory-limit
115+
- *install-php-extensions
109116
- *update-composer
110117
- *update-project-dependencies
111118
- run:
@@ -132,6 +139,7 @@ jobs:
132139
- *restore-npm-cache
133140
- *disable-xdebug-php-extension
134141
- *disable-php-memory-limit
142+
- *install-php-extensions
135143
- *update-composer
136144
- *update-project-dependencies
137145
- *save-composer-cache-by-revision
@@ -177,6 +185,7 @@ jobs:
177185
- *restore-npm-cache
178186
- *disable-xdebug-php-extension
179187
- *disable-php-memory-limit
188+
- *install-php-extensions
180189
- *update-composer
181190
- *update-project-dependencies
182191
- *save-composer-cache-by-revision

.travis.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ cache:
88
jobs:
99
include:
1010
- php: '7.1'
11+
env: NO_UNIT_TESTS=true
12+
before_install:
13+
- composer remove --dev ext-mongodb doctrine/mongodb-odm doctrine/mongodb-odm-bundle
14+
- sed -i '26,32d' tests/Fixtures/app/config/config_common.yml
1115
- php: '7.2'
1216
- php: '7.3'
1317
- php: '7.3'
@@ -26,6 +30,10 @@ jobs:
2630
before_script:
2731
- mysql -e 'CREATE DATABASE api_platform_test;'
2832
env: APP_ENV=mysql
33+
- php: '7.3'
34+
services:
35+
- mongodb
36+
env: APP_ENV=mongodb
2937
- php: '7.3'
3038
services:
3139
- elasticsearch
@@ -40,6 +48,7 @@ before_install:
4048
fi
4149
- phpenv config-rm xdebug.ini || echo "xdebug not available"
4250
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
51+
- echo "extension=mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
4352
- export PATH="$PATH:$HOME/.composer/vendor/bin"
4453

4554
install:
@@ -51,10 +60,17 @@ install:
5160

5261
script:
5362
- tests/Fixtures/app/console cache:clear
54-
- vendor/bin/phpunit
63+
- if [[ $NO_UNIT_TESTS != true ]]; then
64+
vendor/bin/phpunit;
65+
fi
66+
- if [[ $APP_ENV = 'mongodb' ]]; then
67+
vendor/bin/phpunit -c phpunit.mongo.xml;
68+
fi
5569
- tests/Fixtures/app/console cache:clear
5670
- if [[ $APP_ENV = 'postgres' ]]; then
5771
vendor/bin/behat --suite=postgres --format=progress;
72+
elif [[ $APP_ENV = 'mongodb' ]]; then
73+
vendor/bin/behat --suite=mongodb --format=progress;
5874
elif [[ $APP_ENV = 'elasticsearch' ]]; then
5975
vendor/bin/behat --suite=elasticsearch --format=progress;
6076
else

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 2.4.0
44

5+
* MongoDB: full support
56
* Elasticsearch: add reading support (including pagination, sort filter and term filter)
67
* Mercure: automatically push updates to clients using the [Mercure](https://mercure.rocks) protocol
78
* CQRS support and async message handling using the Symfony Messenger Component

appveyor.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,27 @@ install:
99
- ps: Set-Service wuauserv -StartupType Manual
1010
- cinst -y php composer
1111
- refreshenv
12-
- cd c:\tools\php73
12+
- cd c:\tools\php73\ext
13+
- ps: |
14+
$web = New-Object Net.WebClient
15+
$web.Headers.Add('user-agent', 'AppVeyor')
16+
$web.DownloadFile('https://windows.php.net/downloads/pecl/releases/mongodb/1.5.3/php_mongodb-1.5.3-7.3-nts-vc15-x64.zip', 'c:\tools\php73\ext\php_mongodb.zip')
17+
- 7z x php_mongodb.zip -y >nul
18+
- cd ..
1319
- copy php.ini-production php.ini /Y
1420
- echo date.timezone="UTC" >> php.ini
1521
- echo extension_dir=ext >> php.ini
1622
- echo extension=php_openssl.dll >> php.ini
1723
- echo extension=php_mbstring.dll >> php.ini
1824
- echo extension=php_intl.dll >> php.ini
1925
- echo extension=php_pdo_sqlite.dll >> php.ini
26+
- echo extension=php_mongodb.dll >> php.ini
2027
- echo memory_limit=3G >> php.ini
2128
- cd %APPVEYOR_BUILD_FOLDER%
22-
- composer install --no-interaction --no-progress --no-suggest
29+
- composer install --no-interaction --no-progress --no-suggest --ignore-platform-reqs
30+
31+
services:
32+
- mongodb
2333

2434
test_script:
2535
- cd %APPVEYOR_BUILD_FOLDER%

behat.yml.dist

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,25 @@ default:
3838
- 'Behatch\Context\RestContext'
3939
filters:
4040
tags: '~@sqlite&&~@elasticsearch'
41+
mongodb:
42+
contexts:
43+
- 'DoctrineContext':
44+
doctrine: '@doctrine_mongodb'
45+
- 'HttpHeaderContext'
46+
- 'GraphqlContext'
47+
- 'JsonContext'
48+
- 'HydraContext'
49+
- 'SwaggerContext'
50+
- 'HttpCacheContext'
51+
- 'JsonApiContext':
52+
doctrine: '@doctrine_mongodb'
53+
jsonApiSchemaFile: '%paths.base%/tests/Fixtures/JsonSchema/jsonapi.json'
54+
- 'JsonHalContext':
55+
schemaFile: '%paths.base%/tests/Fixtures/JsonHal/jsonhal.json'
56+
- 'Behat\MinkExtension\Context\MinkContext'
57+
- 'Behatch\Context\RestContext'
58+
filters:
59+
tags: '~@sqlite&&~@elasticsearch&&~@!mongodb'
4160
elasticsearch:
4261
paths:
4362
- '%paths.base%/features/elasticsearch'

composer.json

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,13 @@
3333
"behat/symfony2-extension": "^2.1.1",
3434
"behatch/contexts": "3.1.0",
3535
"doctrine/annotations": "^1.2",
36-
"doctrine/doctrine-cache-bundle": "^1.3.5",
3736
"doctrine/doctrine-bundle": "^1.8",
37+
"doctrine/doctrine-cache-bundle": "^1.3.5",
38+
"doctrine/mongodb-odm": "^2.0.0@beta",
39+
"doctrine/mongodb-odm-bundle": "^4.0.0@beta",
3840
"doctrine/orm": "^2.6.3",
3941
"elasticsearch/elasticsearch": "^6.0",
40-
"friendsofsymfony/user-bundle": "^2.1",
42+
"friendsofsymfony/user-bundle": "dev-fix-mongodb-mapping",
4143
"guzzlehttp/guzzle": "^6.0",
4244
"justinrainbow/json-schema": "^5.0",
4345
"nelmio/api-doc-bundle": "^2.13.3",
@@ -77,6 +79,7 @@
7779
"doctrine/common": "<2.7"
7880
},
7981
"suggest": {
82+
"doctrine/mongodb-odm-bundle": "To support MongoDB.",
8083
"elasticsearch/elasticsearch": "To support Elasticsearch.",
8184
"friendsofsymfony/user-bundle": "To use the FOSUserBundle bridge.",
8285
"guzzlehttp/guzzle": "To use the HTTP cache invalidation system.",
@@ -104,5 +107,12 @@
104107
},
105108
"config": {
106109
"sort-packages": true
107-
}
110+
},
111+
"repositories": [
112+
{
113+
"type": "vcs",
114+
"url": "https://github.com/alanpoulain/FOSUserBundle",
115+
"no-api": true
116+
}
117+
]
108118
}

0 commit comments

Comments
 (0)