bengor-user/doctrine-odm-mongodb-bridge
Doctrine ODM MongoDB bridge for BenGorUser, providing adapters to persist and query User domain models with Doctrine ODM. Install via Composer; fully tested with PHPSpec. Documentation lives in the main BenGorUser/User repository.
User component (or similar) with Doctrine ODM for MongoDB, enabling seamless integration of user entities into a NoSQL-backed Laravel application. If the project relies on MongoDB for user data (e.g., flexible schemas, horizontal scaling, or legacy migration), this package provides a lightweight adapter layer.jenssegers/laravel-mongodb). This package is not Laravel-native but could be leveraged in a hybrid stack (e.g., MongoDB for users, SQL for transactions) via Doctrine ODM integration (e.g., doctrine/mongodb-odm).jenssegers/laravel-mongodb) or native Eloquent may suffice. This package adds Doctrine ODM-specific features (e.g., @Document, @EmbeddedDocument) if the team is already using Doctrine.doctrine/mongodb-odm) as a prerequisite. Laravel does not natively support ODM, so this introduces additional complexity (e.g., configuring ODM alongside Eloquent).User interface (e.g., UserInterface, UserProvider). Laravel’s Authenticatable or MustVerifyEmail would need adaptation (e.g., via traits or custom interfaces).users table) would be required.jenssegers/laravel-mongodb vs. Doctrine ODM).@ReferenceOne, @EmbeddedDocument) needed beyond basic CRUD? If not, native MongoDB drivers may be simpler.Auth facade integrate with Doctrine ODM’s UserRepository? Will custom providers be needed?spatie/laravel-mongodb) considered? Why was this chosen?doctrine/mongodb-odm) + Symfony User Component (or Laravel-compatible wrapper).jenssegers/laravel-mongodb + custom User model.doctrine/mongodb-odm-bundle (Symfony) or integrate ODM manually in Laravel.config/packages/doctrine_mongodb_odm.yaml (Symfony) or Laravel service providers.Authenticatable with Doctrine ODM’s @Document annotations.use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use Illuminate\Foundation\Auth\User as Authenticatable;
#[ODM\Document(collection: "users")]
class User extends Authenticatable {
#[ODM\Id(strategy: "UUID")]
protected ?string $id = null;
// Laravel auth fields (email, password_hash)
// Doctrine ODM-specific fields (e.g., roles as @EmbeddedDocument)
}
UserProvider to bridge Doctrine ODM’s UserRepository with Laravel’s Auth system.use Doctrine\ODM\MongoDB\DocumentRepository;
use Illuminate\Contracts\Auth\Authenticatable as LaravelUser;
class DoctrineUserProvider implements UserProviderInterface {
public function retrieveById($identifier): ?LaravelUser {
return $this->odmRepository->find($identifier);
}
// Implement other Auth methods...
}
Hash (password hashing) and Auth facade.User model with the ODM-annotated version.config/auth.php to use the custom DoctrineUserProvider.doctrine/dbal + ODM bulk inserts).$sqlUsers = DB::table('users')->get();
foreach ($sqlUsers as $user) {
$odmUser = new User();
$odmUser->email = $user->email;
$odmUser->password = bcrypt($user->password);
$dm->persist($odmUser);
}
$dm->flush();
User::where() with UserRepository::createQueryBuilder()).AppServiceProvider).Schema builder won’t work with MongoDB. Use Doctrine ODM’s schema validation or manual scripts.auth.login, auth.register events may need custom listeners to work with ODM.HYDRATE_ARRAY) may impact query speed. Benchmark against native MongoDB drivers.doctrine/mongodb-odm and configure MongoDB connection.User model with ODM metadata.DoctrineUserProvider and register it in Laravel’s auth config.@EmbeddedDocument).How can I help you explore Laravel packages today?