Skip to content

Commit

Permalink
Merge pull request #166 from leroy-merlin-br/chore/mongolid-migration-v4
Browse files Browse the repository at this point in the history
Mongolid Migration v4 - Part 1
  • Loading branch information
diegofelix committed Feb 18, 2022
2 parents 50c637d + 72c2144 commit 40a59e1
Show file tree
Hide file tree
Showing 71 changed files with 2,348 additions and 1,656 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

[*.yml]
indent_size = 2
52 changes: 52 additions & 0 deletions .github/pre-commit
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 $?
43 changes: 43 additions & 0 deletions .github/workflows/continuous-integration.yml
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
19 changes: 0 additions & 19 deletions .github/workflows/push.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/site
.idea
coverage
.phpunit.result.cache
20 changes: 20 additions & 0 deletions .mkdocs.yml
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
48 changes: 31 additions & 17 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,59 @@

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making
participation in our project, and our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance,
race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take
appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits,
issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any
contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the
project or its community. Examples of representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed representative at an online or offline
event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at gguitte@leroymerlin.com.br. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at
gguitte@leroymerlin.com.br. The project team will review and investigate all complaints, and will respond in a way that
it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the
reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent
repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
This is an adaptation on Code of Conduct from the [Contributor Covenant][homepage], version 1.4, available at
[http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
CONTAINER_USER="$(shell id -u):$(shell id -g)"

sniff:
docker-compose run --rm php vendor/bin/phpcs ./src --standard='./coding_standard.xml' -n
docker-compose run --rm php vendor/bin/phpcs

phpunit:
docker-compose run --rm php vendor/bin/phpunit
Expand All @@ -8,7 +10,7 @@ coverage:
docker-compose run --rm php vendor/bin/phpunit --coverage-html ./.coverage

mkdocs:
docker-compose run --rm mkdocs mkdocs build --clean
docker-compose run --rm mkdocs mkdocs build --clean -f /workdir/mkdocs/.mkdocs.yml

mkapi:
docker-compose run --rm php vendor/bin/sami.php update sami.php
docker run --rm --user ${CONTAINER_USER} -v ${PWD}:/app --workdir /app --entrypoint /bin/doctum botsudo/action-doctum:v5 update bin/generate-api-docs
86 changes: 24 additions & 62 deletions README.md
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&amp;utm_medium=referral&amp;utm_content=leroy-merlin-br/mongolid&amp;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&amp;utm_medium=referral&amp;utm_content=leroy-merlin-br/mongolid&amp;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&amp;utm_medium=referral&amp;utm_content=leroy-merlin-br/mongolid&amp;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).
17 changes: 17 additions & 0 deletions bin/generate-api-docs
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',
]
);

0 comments on commit 40a59e1

Please sign in to comment.