uedehua / laravel5-doctrine
The Doctrine Orm Form Laravel Framework.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: >=5.5.9
- doctrine/cache: 1.4.*
- doctrine/migrations: dev-master
- doctrine/orm: 2.5.*
- laravel/framework: 5.1.*
This package is not auto-updated.
Last update: 2024-11-09 19:31:45 UTC
README
A Doctrine 2 implementation that melts with Laravel 5.1.X.
Documentation
Begin reading the full documentation here or go to a specific chapter right away.
- 安装
- 它是如何工作的
- 基础
- 实体管理
- Timestamps Trait
- SoftDelete Trait
- Authentication Trait
- Schemas
- Doctrine 配置
- 元数据 配置
- 读取注释
- 元数据
- MIT License
安装
修改项目的 composer.json
文件,添加 uedehua/laravel5-doctrine
"require": { "uedehua/laravel5-doctrine": "5.1.*" }
执行composer更新:
php composer update
添加provider,打开 app/config/app.php
配置文件, 在providers
数组添加一行.
'UeDehua\LaravelDoctrine\Provider\DoctrineOrmProvider'
添加Facade. 打开 app/config/app.php
配置文件, 在aliases
数组添加一行.
'DoctrineOrm' => 'UeDehua\LaravelDoctrine\Facade\DoctrineOrm'
别忘记发布你的配置.
php artisan config:publish uedehua/laravel5-doctrine --path=vendor/uedehua/laravel5-doctrine/config
2 Minutes
这个包使用 Laravel5 本身的数据库配置, 通过 Entity Manager facade (or service locator) 与数据库进行交互. 请参阅 Doctrine 2 文档. 下面的小例子展示了如何在它最简单的形式使用Doctrine ORM.
<?php $user = new User; $user->setName('Mitchell'); EntityManager::persist($user); EntityManager::flush();
添加一个用户到数据库.
<?php use Doctrine\ORM\Mapping AS ORM; /** * @ORM\Entity * @ORM\Table(name="hk_user") */ class User { /** * @ORM\Id * @ORM\GeneratedValue * @ORM\Column(type="integer") */ private $id; /** * @ORM\Column(type="string") */ private $name; public function getId() { return $this->id; } public function getName() { return $this->name; } public function setName($name) { $this->name = $name; } }
User实体基于Annotation,更多请参阅官方文档。
License
This package is licensed under the MIT license.