承接 avris/micrus-doctrine 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

avris/micrus-doctrine

Composer 安装命令:

composer require avris/micrus-doctrine

包简介

Doctrine ORM bridge for the Micrus framework

README 文档

README

This is a module for Micrus framework that allows you to integrate it with Doctrine ORM.

Installation

Run:

composer require avris/micrus-doctrine

Then register the module in your App\App:registerModules:

yield new \Avris\Micrus\Doctrine\DoctrineModule;

Finally, run:

bin/env

You will be asked for a connection string and it will be saved in the .env file.

EntityManager

DoctrineManager will scan all modules for a /src/Entity directory and if it's there -- it will automatically register all classes from this directory as doctrine entities.

Doctrine's EntityManager is registered in the container as Doctrine\ORM\EntityManagerInterface:

public function incrementStuffAction(EntityManagerInterface $em)
{
    $stuff = $em->getRepository('Stuff')->findBySomeCustomCondition();
    $stuff->incrementValue();
    $em->persist($stuff);
    $em->flush();
    $this->addFlash('success', 'Stuff incremented successfully');

    return $this->redirectToRoute('home');
}

UserProvider

This module registers Doctrine as the UserProvider. It will try to find a user from App\Entity\User repository using email as identifier. To modify those values, just use the container:

Avris\Micrus\Doctrine\DoctrineUserProvider:
  arguments:
    $column: username

MatchProvider

Doctrine will automatically match the arguments of your controller if they are entities, for example:

/**
 * @M\Route("/post/{int:id}/read")
 */
public function readAction(Post $post) { }

For request GET /post/8/read will try to find App\Entity\Post with id = 8 and either return it or throw a NotFoundHttpException if failed.

Console

Some Doctrine console commands are available in bin/micrus under db namespace:

php bin/micrus db:schema:create
php bin/micrus db:schema:update
php bin/micrus db:schema:validate
php bin/micrus db:schema:drop
 
php bin/micrus db:query:sql "SELECT * FROM user"
php bin/micrus db:query:dql "SELECT u FROM App\Model\User u WHERE u.role='ROLE_ADMIN'"

Copyright

统计信息

  • 总下载量: 305
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 5
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-03-03

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固