承接 psykosoldi3r/slim-doctrine 相关项目开发

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

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

psykosoldi3r/slim-doctrine

Composer 安装命令:

composer require psykosoldi3r/slim-doctrine

包简介

Doctrine middleware for Slim Framework 3

README 文档

README

Doctrine middleware for Slim Framework 3 (only tested on 3.5)

Install

Composer (https://getcomposer.org)

composer require psykosoldi3r/slim-doctrine

Usage

After installing slim-doctrine you will need to initialize it in your Slim Framework application.

Initialize Doctrine

$doctrine = new \Slim\Middleware\Doctrine( \Slim\Container $container, array $configuration );

$container = Container for your Slim App
$configuration = Associative array

Example

<?php

require 'vendor/autoload.php';

$container = new \Slim\Container;
$app = new \App\App( $container );

$doctrine = new \Slim\Middleware\Doctrine(
    $app->getContainer(),
    array(
        "dev_mode" => true,
        "entities" => [
            "paths" => ["src/App/Entity"]
        ],
        "connection" => [
            "driver"    => "pdo_mysql",
            "host"      => "127.0.0.1",
            "dbname"    => "slim_doctrine_demo",
            "user"      => "root",
            "password"  => "root"
        ]
    ));

$app->run();

Config

At this moment the following config is supported. More information can be found at: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/configuration.html

"dev_mode" => true/false,
"entities" => [
    "paths" => ["src/App/Entity", ...]
],
"connection" => [
    "driver"    => "pdo_mysql",
    "host"      => "127.0.0.1",
    "dbname"    => "slim_doctrine_demo",
    "user"      => "root",
    "password"  => "root"
]

Controllers

It's also possible to get access to the Entity Manager by extending your controllers with \Slim\Middleware\DoctrineResource class. You can then easily gain access to the EntityManager by using $this->getEntityManager()

Example

<?php

namespace App\Controllers;

use Interop\Container\ContainerInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Slim\Middleware\DoctrineResource;

class QuestionController extends DoctrineResource
{
    public function __construct( ContainerInterface $ci ){
        parent::__construct( $ci );
    }
    
    public function exampleAction( ServerRequestInterface $request, ResponseInterface $response, $args ){
        $em = $this->getEntityManager();
    }
}

Issue & Pull Request

Feel free to create new issue's on this repository for bugs, feature requests and questions. Have you fixed any issue or something else related to this project, feel free to create a pull requests.

Contact

For any other questions you can ask it to my on Twitter: @JoeyNL

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固