-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(WIP) V3 #133
Closed
Closed
(WIP) V3 #133
Changes from 119 commits
Commits
Show all changes
133 commits
Select commit
Hold shift + click to select a range
de412eb
Use LMBR Coding Standard
carusogabriel fbc9a09
Move files and drop bootstrap file
b82b881
Ignore some files when exporting package
c3c2efd
Merge branch 'master' into coding-standard
3f93cfe
Require PHP >= 7.1
14e35e2
Merge pull request #129 from leroy-merlin-br/coding-standard
ravanscafi 0c1aaaa
Merge branch 'v3' into improve-exports
372de06
Fix CS for new structure
d20040f
Update readme, license and composer.json files
5a94fa1
Fix Schema tests namespace
8f226bc
Use new mockery syntax
c739689
Commit lock file to speed up installation
ravanscafi d25d995
Move unit tests
ravanscafi 5c84b67
Create integration tests folder and testsuite
ravanscafi e57aba6
Fix CS rules
ravanscafi 3d1ba75
Add pre-commit hook
ravanscafi 6d800c5
Create integration test to ensure no regressions later
ravanscafi 06e1e9a
Fix travis
ravanscafi 6920ac7
Update .gitattributes
ravanscafi cb97919
Drop connection pool
ravanscafi 4e6111c
Use atomic updates for update() method of data mapper
d6fb298
Allow modification of array values directly
367c77d
Allow integration testes to be accounted on coverage results
9254781
Merge pull request #134 from leroy-merlin-br/update-method
ravanscafi 83ea3b9
Move Manager to Connections Namespace
352a7c4
Move ActiveRecord to Model Namespace
b8f1fe3
Prevent query 'first(null)' to hit the database
d942731
Make mutable field protected
965736c
Small improvements
647b1e8
Rename model attributes and original attributes
1e0768f
Create integration tests for relationships by reference
7526185
Improve coverage a bit
7b91123
Update composer and coveralls dependency
ravanscafi 0d4811f
Suggest installing mongolid-laravel package
8c01f76
Update travis CI script and allow PHP 7.3 to run
336d3c0
Remove get_class() and improve CursorInterface
f2e77e0
Replace Ioc:instance() calls
adf459c
Simplify protected helpers
a5b9d60
Replace self::class with static::class and makeWith with make
1b9aa82
Revert change that is breaking on CI
6129370
Change document attributes based on team feedback
41b6e47
Fix mutator names for snake_case attributes
de572cd
Rename traits, interfaces and abstract classes to follow code standard
b23f6a9
Improve a bit the relation between AbstractActiveRecord and HasAttrib…
b76436e
New draft for relations
92863d0
Fix HasRelationsTraitTest tests
d0d9db0
Improve how embedded relations are returned
7c32eec
Improve tests scenarios
664964c
Drop unused method
8da2eb6
Improve polymorph docs a bit
0872145
Allow relations by other reference field
1636e90
Infer relation names
89ca2fe
Create RelationInterface and validate attribute access of methods
a539751
Flip attributes to follow the same order as parent
336795e
Rename exception to be clearer
7ca5c81
Prevent field name from being the same as the relation name
851f723
Fixes based on review
c4f2dc2
Add a test for old reserved words
e681058
Improve attributes test
a715c5b
New cache strategy for relations
534b3a1
Invalidate relation cache when unsetting field
d81e1ee
Invalidate relation cache when setting field directly
0970c55
Simplify logic relations' cached results
9b00a84
Prevent EmbedsOne and ReferencesOne to have more than one relation
d062cae
Merge pull request #136 from leroy-merlin-br/new-relations
ravanscafi d30e5f9
Fix regression on DataMapper Events
91d4272
Fix regression where DocumentEmbedder would not trigger setDocumentAt…
71320a2
Only create relations with objects, embed only attributes and create …
ef44a0f
Parse document to consider fields when embedding models
f961c88
Add new test to make sure that date queries works
d883c3f
Fix LogicException bug (probably mongodb bug?) and add test to it
db7c3d2
Use CachingIterator to wrap cursor
3949f51
Some improvements on Cursors
bef0a6a
Remove cacheable cursor implementation
3f79f96
Drop cursor factory
fc9057a
"Drop" DataMapper pattern
d73397d
Implement Persistable interface and simplify logic for parsing documents
0266e3c
Merge branch 'master' into v3
cad488a
Improve docker configuration
b0b272f
Set schema for broken tests
e368033
Simplify schema use, drop model assembler and polymorphable interface
4d8605d
Drop schemas in favor of bson serialization
6881038
Update readme
a10fee3
Improve test steps
7b5e3fa
Only report coverage for version 7.2 and ensure it runs on 7.3
ba1aaa8
Fix wrong renaming
74292fc
Make fill method static and change signature to allow object to be pa…
00c7c13
Move stubs to common tests namespace
5ede2ab
Use stubs for Relations test
ee46457
Create new polymorphable model interface
63e8fb0
Merge pull request #139 from leroy-merlin-br/new-polymorph
ravanscafi 9c526bf
Add __pclass field to projection
16a64fa
Move document embedder to relations namespace
edd9472
Remove DocumentEmbedder and simplify relations with only one model
4b4d0f8
Add Arrayable interface to Cursor interface
8812721
Simplify query builder test
6ff6c7e
Add test to ensure that cursor preferences are not overriding each other
5b1e07b
Fix coverage reporting
b4bf013
Renaming rawCollection to client
0761aba
Add integration test for BulkWrite
2b3abf7
Use bulkwrite method from collection to simplify things a bit
a17f564
Drop getManager from Connection as it is not used anymore
75835ac
Create getCollection on Model to simplify interacting with MongoDB Co…
9020d17
Rename Ioc to Container
d2ae4dd
Fix method isEmpty of BulkWrite and ensure it is empty after running
ebec1bd
100% coverage
6247351
Use implemented getCollection for test stubs
e384914
Update travis script
b52b7c2
Change requirements order on readme
45270fa
Use container to create instances on fill method
a70d798
Consider model attributes when checking for polymorph class
61d282c
Unset field when value is null
8b4d663
Clean null attributes when retrieving them
72dc4fd
Fix embedded models being retrieved as arrays instead of objects
5605f45
Fix test that was breaking on CI
18926ad
Remove unused variable
e255ec0
Small tweaks
7ac32b1
Use container to manage timestamps and id on ModelMapper
5bdf0bc
Add a test to ensure that embedded models are correctly updated
499225c
Update phpunit and illuminate dependencies
ravanscafi 9a2b408
Bump php minimum version to 7.2
ravanscafi eba5082
Attempt to bump mongodb driver version
ravanscafi 063ef4c
Merge branch 'master' into v3
ravanscafi 2928b07
Configure mongodb extension on travis
ravanscafi cd8646f
Upgrade illuminate dependencies (#147)
Edukazan f1d8ddc
Update our CS version
4191a00
Allow Laravel 8.*
cfb4317
Replace Sami by Doctum
williamdes 9565893
Merge pull request #150 from wdesportes/master
c1a731c
feat: remove typos from README.md
49b03f6
fix: covenant code of conduct typos
d9bb795
fix: use a heading instead of use emphasis
6d33573
Merge pull request #155 from leroy-merlin-br/docs/remove-typos
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Path-based git attributes | ||
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html | ||
|
||
# Ignore all test and documentation with "export-ignore". | ||
# Folders | ||
/.github export-ignore | ||
/docs export-ignore | ||
/tests export-ignore | ||
# Files | ||
/.coveralls.yml export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.travis.yml export-ignore | ||
/CODE_OF_CONDUCT.md export-ignore | ||
/composer.lock export-ignore | ||
/docker-compose.override.yml.example export-ignore | ||
/docker-compose.yml export-ignore | ||
/Makefile export-ignore | ||
/mkdocs.yml export-ignore | ||
/phpcs.xml export-ignore | ||
/phpunit.xml export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/sami.php export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash | ||
|
||
STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR | grep \.php` | ||
|
||
# Determine if a file list is passed | ||
if [ "$#" -eq 1 ] | ||
then | ||
oIFS=$IFS | ||
IFS=' | ||
' | ||
SFILES="$1" | ||
IFS=$oIFS | ||
fi | ||
SFILES=${SFILES:-$STAGED_FILES_CMD} | ||
|
||
# Fix path for docker | ||
for FILE in $SFILES | ||
do | ||
FILES="$FILES $FILE" | ||
done | ||
|
||
if [ "$FILES" != "" ] | ||
then | ||
echo -e "\033[1;33m"Running Code Sniffer..."\033[0m" | ||
docker-compose run --rm --no-deps -T php vendor/bin/phpcs $FILES | ||
|
||
if [ $? != 0 ] | ||
then | ||
# Allows us to read user input below, assigns stdin to keyboard | ||
exec < /dev/tty | ||
|
||
read -p "There are some Coding Standards violations. Do you want to fix the auto-fixable ones? (Yes) " choice | ||
[ "$choice" = "" ] && choice='Y' | ||
|
||
case ${choice:0:1} in | ||
y|Y ) | ||
echo -e "\033[1;33m"Running Code Beautifier..."\033[0m" | ||
docker-compose run --rm --no-deps -T php vendor/bin/phpcbf $FILES | ||
echo -e "\033[0;32m"Done. Please add the fixes before commit."\033[0m" | ||
|
||
exit 1 | ||
;; | ||
* ) | ||
echo -e "\033[41m"Please, fix the Coding Standards violations before commit."\033[0m" | ||
|
||
exit 1 | ||
;; | ||
esac | ||
fi | ||
fi | ||
|
||
exit $? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
/.coverage | ||
/build | ||
/site | ||
composer.lock | ||
.phpcs-cache | ||
docker-compose.override.yml |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,26 @@ | ||
language: php | ||
|
||
php: | ||
- 7.0 | ||
- 7.1 | ||
- 7.2 | ||
- 7.3 | ||
|
||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
|
||
services: mongodb | ||
|
||
before_install: | ||
- if [[ $TRAVIS_PHP_VERSION != 7.2 ]]; then pecl install mongodb; fi | ||
- if [[ $(phpenv version-name) = "7.1" ]]; then pecl install mongodb; fi | ||
- echo "extension = mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini | ||
|
||
before_script: | ||
- composer install --no-interaction | ||
|
||
script: | ||
- mkdir -p build/logs | ||
- phpunit -c phpunit.xml.dist && make sniff | ||
- vendor/bin/phpcs | ||
- vendor/bin/phpunit -c phpunit.xml.dist | ||
|
||
after_script: | ||
- php vendor/bin/coveralls -v | ||
after_success: | ||
- if [[ $(phpenv version-name) = "7.2" ]]; then php vendor/bin/php-coveralls -v; fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,45 @@ | ||
# Mongolid ODM for MongoDB (PHP7) | ||
# Mongolid ODM for MongoDB | ||
|
||
> Easy, powerful and ultrafast ODM for PHP7 build on top of the [new mongodb driver](https://docs.mongodb.org/ecosystem/drivers/php/). | ||
<p align="center"><img src="https://user-images.githubusercontent.com/1991286/28967747-fe5c258a-78f2-11e7-91c7-8850ffb32004.png" alt="Mongolid"></p> | ||
|
||
![Mongolid](https://user-images.githubusercontent.com/1991286/28967747-fe5c258a-78f2-11e7-91c7-8850ffb32004.png) | ||
<p align="center"> | ||
<a href="https://travis-ci.org/leroy-merlin-br/mongolid"><img src="https://travis-ci.org/leroy-merlin-br/mongolid.svg?branch=master" alt="Build Status"></a> | ||
<a href="https://coveralls.io/github/leroy-merlin-br/mongolid?branch=master"><img src="https://coveralls.io/repos/github/leroy-merlin-br/mongolid/badge.svg?branch=master" alt="Coverage Status"></a> | ||
<a href="https://packagist.org/packages/leroy-merlin-br/mongolid"><img src="https://poser.pugx.org/leroy-merlin-br/mongolid/v/stable" alt="Latest Stable Version"></a> | ||
<a href="https://packagist.org/packages/leroy-merlin-br/mongolid"><img src="https://poser.pugx.org/leroy-merlin-br/mongolid/downloads" alt="Total Downloads"></a> | ||
<a href="https://packagist.org/packages/leroy-merlin-br/mongolid"><img src="https://poser.pugx.org/leroy-merlin-br/mongolid/license" alt="License"></a> | ||
</p> | ||
|
||
Mongolid supports both **ActiveRecord** and **DataMapper** patterns. **You choose! (:** | ||
## About Mongolid | ||
Easy, powerful and ultrafast ODM for PHP 7.1+ build on top of the [new mongodb driver](https://docs.mongodb.org/ecosystem/drivers/php/). | ||
|
||
[![Build Status](https://travis-ci.org/leroy-merlin-br/mongolid.svg?branch=master)](https://travis-ci.org/leroy-merlin-br/mongolid) | ||
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/cc45e93bb0d0413d9e0355c7377d4d33)](https://www.codacy.com/app/zizaco/mongolid?utm_source=github.com&utm_medium=referral&utm_content=leroy-merlin-br/mongolid&utm_campaign=Badge_Grade) | ||
[![StyleCI](https://styleci.io/repos/9799450/shield?branch=master)](https://styleci.io/repos/9799450) | ||
[![Coverage Status](https://coveralls.io/repos/github/leroy-merlin-br/mongolid/badge.svg?branch=master)](https://coveralls.io/github/leroy-merlin-br/mongolid?branch=master) | ||
[![Latest Stable Version](https://poser.pugx.org/leroy-merlin-br/mongolid/v/stable)](https://packagist.org/packages/leroy-merlin-br/mongolid) | ||
[![Total Downloads](https://poser.pugx.org/leroy-merlin-br/mongolid/downloads)](https://packagist.org/packages/leroy-merlin-br/mongolid) | ||
[![Latest Unstable Version](https://poser.pugx.org/leroy-merlin-br/mongolid/v/unstable)](https://packagist.org/packages/leroy-merlin-br/mongolid) | ||
[![License](https://poser.pugx.org/leroy-merlin-br/mongolid/license)](https://packagist.org/packages/leroy-merlin-br/mongolid) | ||
Mongolid supports **ActiveRecord** pattern. | ||
|
||
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/25636a94-9a5d-4438-bd5e-9f9694104529/small.png)](https://insight.sensiolabs.com/projects/25636a94-9a5d-4438-bd5e-9f9694104529) | ||
|
||
<a name="introduction"></a> | ||
## Introduction | ||
|
||
Mongolid ODM (Object Document Mapper) provides a beautiful, simple implementation for working with MongoDB. Each database collection can have a corresponding "Model" which is used to interact with that collection. | ||
|
||
> **Note:** If you are working with Laravel, take a look at [mongolid-laravel repository](https://github.com/leroy-merlin-br/mongolid-laravel). | ||
|
||
<a name="installation"></a> | ||
## Installation | ||
|
||
You can install library through Composer: | ||
|
||
``` | ||
$ composer require leroy-merlin-br/mongolid | ||
``` | ||
**Note:** If you are working with Laravel, take a look at [mongolid-laravel repository](https://github.com/leroy-merlin-br/mongolid-laravel). | ||
|
||
### Requirements | ||
|
||
- PHP**7** | ||
## Requirements | ||
- PHP **7.1** or superior | ||
- [MongoDB Driver](http://php.net/manual/en/set.mongodb.php) | ||
|
||
> **Note:** If you are looking for the old PHP 5.x version, head to the [v0.8 branch](https://github.com/leroy-merlin-br/mongolid/tree/v0.8-dev). | ||
|
||
## [Read the Docs: <small>leroy-merlin-br.github.com/mongolid</small>](http://leroy-merlin-br.github.com/mongolid) | ||
[![Mongolid Docs](https://dl.dropboxusercontent.com/u/12506137/libs_bundles/MongolidDocs.png)](http://leroy-merlin-br.github.com/mongolid) | ||
|
||
<a name="troubleshooting"></a> | ||
## Troubleshooting | ||
|
||
**"PHP Fatal error: Class 'MongoDB\Client' not found in ..."** | ||
|
||
The `MongoDB\Client` class is contained in the [**new** MongoDB driver](http://pecl.php.net/package/mongodb) for PHP. [Here is an installation guide](http://www.php.net/manual/en/mongodb.installation.php). The driver is a PHP extension written in C and maintained by [MongoDB](https://mongodb.com). Mongolid and most other MongoDB PHP libraries utilize it in order to be fast and reliable. | ||
|
||
**"Class 'MongoDB\Client' not found in ..." in CLI persists even with MongoDB driver installed.** | ||
|
||
Make sure that the **php.ini** file used in the CLI environment includes the MongoDB extension. In some systems, the default PHP installation uses different **.ini** files for the web and CLI environments. | ||
|
||
Run `php -i | grep 'Configuration File'` in a terminal to check the **.ini** that is being used. | ||
|
||
To check if PHP in the CLI environment is importing the driver properly run `php -i | grep -i 'mongo'` in your terminal. You should get output similar to: | ||
## Installation | ||
You can install the library through Composer: | ||
|
||
``` | ||
$ php -i | grep -i 'mongo' | ||
MongoDB support => enabled | ||
MongoDB extension version => 1.2.8 | ||
MongoDB extension stability => stable | ||
libmongoc bundled version => 1.5.5 | ||
$ composer require leroy-merlin-br/mongolid | ||
``` | ||
|
||
**"This package requires php >=7.0 but your PHP version (X.X.X) does not satisfy that requirement."** | ||
|
||
The new (and improved) version 2.0 of Mongolid requires php7. If you are looking for the old PHP 5.x version, head to the [v0.8 branch](https://github.com/leroy-merlin-br/mongolid/tree/v0.8-dev). | ||
## Documentation | ||
You can access the full documentation [here](http://leroy-merlin-br.github.com/mongolid). | ||
|
||
<a name="license"></a> | ||
## License | ||
Mongolid is free software distributed under the terms of the [MIT license](LICENSE). | ||
|
||
Mongolid is free software distributed under the terms of the [MIT license](http://opensource.org/licenses/MIT) | ||
|
||
<a name="additional_information"></a> | ||
## Additional information | ||
Made with ❤ by [Leroy Merlin Brazil](https://github.com/leroy-merlin-br) and [all contributors](https://github.com/leroy-merlin-br/mongolid/graphs/contributors). | ||
|
||
Mongolid was proudly built by the [Leroy Merlin Brazil](https://github.com/leroy-merlin-br) team. [See all the contributors](https://github.com/leroy-merlin-br/mongolid/graphs/contributors). | ||
|
||
Any questions, feel free to contact us. | ||
If you have any questions, feel free to contact us. | ||
|
||
Any issues, please [report here](https://github.com/Zizaco/mongolid) | ||
If you any issues, please [report here](https://github.com/leroy-merlin-br/mongolid/issues). |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.