-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from leroy-merlin-br/chore/mongolid-migration-v4
Mongolid Migration v4 - Part 1
- Loading branch information
Showing
71 changed files
with
2,348 additions
and
1,656 deletions.
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 |
---|---|---|
|
@@ -17,3 +17,5 @@ insert_final_newline = true | |
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.yml] | ||
indent_size = 2 |
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Continuous Integration | ||
on: | ||
- pull_request | ||
- push | ||
jobs: | ||
testing: | ||
name: Tests | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
php: | ||
- "7.3" | ||
- "7.4" | ||
mongo: | ||
- "3.6" | ||
- "4.0" | ||
- "4.2" | ||
- "4.4" | ||
services: | ||
mongodb: | ||
image: mongo:${{ matrix.mongo }} | ||
ports: | ||
- "27017:27017" | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: PHP setup | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
|
||
- name: Composer | ||
uses: ramsey/composer-install@v1 | ||
|
||
- name: Running tests | ||
run: vendor/bin/phpunit -c phpunit.xml.dist --coverage-clover=./coverage/clover.xml | ||
|
||
- name: Report coverage | ||
uses: codacy/codacy-coverage-reporter-action@v1 | ||
with: | ||
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | ||
coverage-reports: ./coverage/clover.xml |
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 |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
/site | ||
.idea | ||
coverage | ||
.phpunit.result.cache |
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,20 @@ | ||
site_name: "Mongolid ODM" | ||
site_url: http://leroy-merlin-br.github.io/mongolid | ||
repo_url: https://github.com/leroy-merlin-br/mongolid | ||
|
||
theme: readthedocs | ||
|
||
nav: | ||
- 'Home': 'index.md' | ||
- 'Basics': 'basics.md' | ||
- 'Relationships': 'relationships.md' | ||
- 'API Documentation': 'api-docs.md' | ||
- 'Troubleshooting': 'troubleshooting.md' | ||
- 'Additional information': 'info.md' | ||
|
||
markdown_extensions: | ||
- def_list | ||
- fenced_code | ||
- smarty | ||
- toc: | ||
permalink: true |
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,83 +1,45 @@ | ||
# Mongolid ODM for MongoDB (PHP7) | ||
|
||
> Easy, powerful and ultrafast ODM for PHP7 build on top of the [new mongodb driver](https://docs.mongodb.org/ecosystem/drivers/php/). | ||
![Mongolid](https://user-images.githubusercontent.com/1991286/28967747-fe5c258a-78f2-11e7-91c7-8850ffb32004.png) | ||
|
||
Mongolid supports both **ActiveRecord** and **DataMapper** patterns. **You choose! (:** | ||
<p align="center"> | ||
|
||
[![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) | ||
[![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) | ||
[![Continuous Integration](https://github.com/leroy-merlin-br/mongolid/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/leroy-merlin-br/mongolid/actions/workflows/continuous-integration.yml) | ||
<a href="https://www.codacy.com/gh/leroy-merlin-br/mongolid/dashboard?utm_source=github.com&utm_medium=referral&utm_content=leroy-merlin-br/mongolid&utm_campaign=Badge_Grade"><img src="https://app.codacy.com/project/badge/Grade/bdda2d9ea3e94141946af9bad2da1a09"/></a> | ||
<a href="https://www.codacy.com/gh/leroy-merlin-br/mongolid/dashboard?utm_source=github.com&utm_medium=referral&utm_content=leroy-merlin-br/mongolid&utm_campaign=Badge_Coverage"><img src="https://app.codacy.com/project/badge/Coverage/bdda2d9ea3e94141946af9bad2da1a09"/></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> | ||
|
||
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/25636a94-9a5d-4438-bd5e-9f9694104529/small.png)](https://insight.sensiolabs.com/projects/25636a94-9a5d-4438-bd5e-9f9694104529) | ||
## About Mongolid | ||
Easy, powerful and ultrafast ODM for PHP 7.3+ build on top of the [new mongodb driver](https://docs.mongodb.org/ecosystem/drivers/php/). | ||
|
||
<a name="introduction"></a> | ||
## Introduction | ||
Mongolid supports **ActiveRecord** pattern. | ||
|
||
## 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: | ||
**Note:** If you are working with Laravel, take a look at [mongolid-laravel repository](https://github.com/leroy-merlin-br/mongolid-laravel). | ||
|
||
``` | ||
$ composer require leroy-merlin-br/mongolid | ||
``` | ||
|
||
### Requirements | ||
|
||
- PHP**7** | ||
## Requirements | ||
- PHP **7.3** 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."** | ||
## Documentation | ||
You can access the full documentation [here](http://leroy-merlin-br.github.io/mongolid). | ||
|
||
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). | ||
|
||
<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 have any issues, please [report here](https://github.com/leroy-merlin-br/mongolid/issues). |
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,17 @@ | ||
#!/usr/bin/php | ||
<?php | ||
|
||
/** | ||
* Doctum configuration file. | ||
* | ||
* @see https://github.com/code-lts/doctum#readme | ||
*/ | ||
|
||
return new Doctum\Doctum( | ||
'./src', | ||
[ | ||
'title' => 'Mongolid ODM Api', | ||
'build_dir' => __DIR__.'/../site/api', | ||
'cache_dir' => __DIR__.'/../build/cache', | ||
] | ||
); |
Oops, something went wrong.