Skip to content
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

Remove Mongo from Phalcon #13697

Closed
niden opened this issue Dec 24, 2018 · 18 comments
Closed

Remove Mongo from Phalcon #13697

niden opened this issue Dec 24, 2018 · 18 comments
Labels
breaks bc Functionality that breaks Backwards Compatibility

Comments

@niden
Copy link
Member

niden commented Dec 24, 2018

Since there is no support for the existing driver for PHP, we have to remove Mongo from this release.

There is a plan to re-introduce it in the future as a storage adapter and with that we can re-introduce the Mvc\Collection class or something similar

@niden niden added the breaks bc Functionality that breaks Backwards Compatibility label Dec 24, 2018
@ViltusVilks
Copy link

What do You mean by removing Mongo? Remove direct "usage" of mongo in .zep and also remove ODM completely in 4.0 release?

@niden
Copy link
Member Author

niden commented Jan 3, 2019

@ViltusVilks Remove the current driver (Mongo driver) that Phalcon uses to interact with Mongo because it has been deprecated. That will mean that the ODM will not work for a period of time until the new driver is introduced.

If we can do this in one go that would be great.

@ViltusVilks
Copy link

Huh, deprecated? What is this? https://pecl.php.net/package/mongodb
Or I do not understand what is deprecated (Phalcon support for ODM/Mongo compatibility, or Mongo decided to drop support for MongoDB native driver (NETLIB)?)

I am working on dokerized Phalcon-ODM-only project to make slim, fast and scalable image. Without ODM project is dead :(

@niden
Copy link
Member Author

niden commented Jan 3, 2019

@ViltusVilks It is the driver itself. Phalcon has been using this driver:

http://php.net/manual/en/book.mongo.php

and we need to change it to this driver

http://php.net/manual/en/set.mongodb.php

@niden
Copy link
Member Author

niden commented Jan 3, 2019

It is a matter of time and resources really. We have not "removed" anything with regards to the Mongo functionality. If you have the first driver installed then it will work I think. I really don't know the changes that 7.2 brought in that aspect of PHP.

Removing mongo functionality including the ODM in one release and reintroducing it properly tested and upgraded is the plan. It has not materialized yet since we have not finished the release - still in alpha

@ViltusVilks
Copy link

Ah... this is old one driver!
Just for information - I am using incubator github project, which overrides collection and uses new driver. I also utilize GridFS features.

And everything works fine php7.2.13 + 3.4.2 on Alpine 3.8 :)
Have You checked that?

Shortcut - base collection class which is replacing Mvc\Collection. (i am using in Models namespace)
https://github.com/phalcon/incubator/blob/master/Library/Phalcon/Mvc/MongoCollection.php

If that stuff can be "ported" to .zep ... on re-implemented /cleaned.

@wajdijurry
Copy link

wajdijurry commented Jan 3, 2019 via email

@niden
Copy link
Member Author

niden commented Jan 3, 2019

@ViltusVilks Yes that is the plan. To upgrade the driver and clean things up. Right now we don't have a lot of time so this is why I wrote we need to remove it and bring it back fresh.

The "removal" will be temporary of course. We are not killing the component.

@npfedwards
Copy link
Contributor

@niden I thought we'd always had to use the incubator version and that was using the new driver (since php7.0?). I'm a complete mongo convert so this is kinda important to me. Very willing to take a look at this once I've got used to writing the tests etc.

@ViltusVilks
Copy link

Yep, incubator is good and can be taken as an "example".

FYI: Just tryied to convert simple ODM models/code for Phalcon4 by modifing incubator code, it does not work, because of strict-type on interfaces on return types :(

Basically Phalcon4 should provide generic collection+manager with possibility to attach any backend adapter capable to handle Document store and query (incl. Solr, Elastic ...)

@niden
Copy link
Member Author

niden commented Jan 4, 2019

@npfedwards More than welcome to give it a go i.e. have the incubator code completely tested and working with the new driver. Then we can relatively easily port it to zephir

@ViltusVilks I agree. I came up with this issue when I was trying to align the interfaces between find/findFirst of the model and find/findFirst of a document.

A brand new interface for a Document object is a must as you mentioned. We can then have adapters for the back end and handle any number of nosql or similar stores. That however will have to wait a bit until implemented.

I envision this:

  • Phalcon\Storage -> collection of low level adapters that will write data to a store. This could be file system, stream, Redis, Mongo or whatever. All use a simple interface to allow for more adapters (something in the lines of FlySystem from phptheleague)
  • Use those storage adapters everywhere: Cache, Metadata, Session etc.
  • Use wrapper around that adapter to offer Document objects for nosql or similar stores

@npfedwards
Copy link
Contributor

@niden Sure. I'll have a go making sure the current incubator code is tested (I've been using it for a while so I'm pretty sure it works ;)). And then given I want to expand my knowledge I'll have a go porting it to Zephir. I expect it to be a few week project for me but expect a pull request in a while.

@niden
Copy link
Member Author

niden commented Jan 5, 2019

@npfedwards sounds like a plan. We have time so no worries. I need to figure out the Document class. How it will be and what it will have in it to help with all the crud and stuff. The existing one needs definitely some love.

@ViltusVilks
Copy link

ViltusVilks commented Feb 4, 2019

Some news.
I have got working Phalcon v4.alpha2 (v 7.2.14 only, 7.3.1 has segmentation fault) with Incubator adapter and some small changes

Of cause you need do some code fixes like getSource() : string and etc typed returns for interface functions, but quering and save works fine :)

CollectionInterface, propper return type

/**
	 * Allows to query the first record that match the specified conditions
	 */
	public static function findFirst(array parameters = null) -> <CollectionInterface> | null;

MongoCollecto@Incubator, do the same

    // @codingStandardsIgnoreStart
    static protected $_disableEvents = false;
    // @codingStandardsIgnoreEnd

    public static function findFirst(array $parameters = null) : \Phalcon\Mvc\CollectionInterface
...

@ghost
Copy link

ghost commented Feb 9, 2019

@niden This is similar to what I was requesting as NFR [1] Its a great idea having Phalcon\Collection with CRUD support. It can use similar functions like in ODM [2] I specificly requested JSON adapter (flat-file-storage) because this is my own preference. But it can easily be extended to YAML and pure flat-file-storage similar to cache in Phalcon now but with much more control over it like sub-folders and search.

[1] #13783
[2] https://docs.phalconphp.com/3.2/en/db-odm

@SidRoberts
Copy link
Contributor

Does anyone have any updates on this?

@niden
Copy link
Member Author

niden commented May 4, 2019

@SidRoberts From what I mentioned in a comment above, the storage adapters and the structure is there in the PSR-16 branch (my fork). Once that gets merged into 4.0.x we will have the structure to implement a mongo adapter using the latest driver. After that we can implement the Collection component that is aligned with the Resultset one.

There were a couple of members of the community that have been working on setting up the mongo collection with the latest mongo driver offering better compatibility with the latest and greatest mongo functionality.

Honestly I don't know about the timing on this i.e. whether we will have time to replace the mongo driver. For v4 we just might remove it and introduce it to v4.1. I think we can do this but I have to check SemVer if we can do it in a med version.

@tacxou
Copy link

tacxou commented May 5, 2019

Hello, I propose a (temporary) implementation while waiting for the total rewriting of the collections with MongoDb / PHP7. There is probably still work to be done, and unit tests must be done. The goal is to offer support for the new MongoDb driver for corporate projects

niden added a commit that referenced this issue Sep 7, 2019
niden added a commit that referenced this issue Sep 7, 2019
niden added a commit that referenced this issue Sep 7, 2019
niden added a commit that referenced this issue Sep 7, 2019
niden added a commit that referenced this issue Sep 7, 2019
niden added a commit that referenced this issue Sep 7, 2019
niden added a commit that referenced this issue Sep 7, 2019
niden added a commit that referenced this issue Sep 7, 2019
niden added a commit that referenced this issue Sep 7, 2019
@stale stale bot added the stale Stale issue - automatically closed label Nov 16, 2019
@phalcon phalcon deleted a comment from stale bot Nov 16, 2019
@stale stale bot removed the stale Stale issue - automatically closed label Nov 16, 2019
@stale stale bot added the stale Stale issue - automatically closed label Mar 23, 2020
@phalcon phalcon deleted a comment from stale bot Mar 23, 2020
@stale stale bot removed the stale Stale issue - automatically closed label Mar 23, 2020
@stale stale bot added the stale Stale issue - automatically closed label Jun 22, 2020
@stale stale bot closed this as completed Jun 23, 2020
@phalcon phalcon deleted a comment from stale bot Jun 23, 2020
@niden niden reopened this Jun 23, 2020
@stale stale bot removed the stale Stale issue - automatically closed label Jun 23, 2020
@Jeckerson Jeckerson removed the 4.1.0 label Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaks bc Functionality that breaks Backwards Compatibility
Projects
Archived in project
Development

No branches or pull requests

7 participants