在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):mitchellvanw/laravel-doctrine开源软件地址(OpenSource Url):https://github.com/mitchellvanw/laravel-doctrine开源编程语言(OpenSource Language):PHP 100.0%开源软件介绍(OpenSource Introduction):laravel-doctrine/orm instead!)Doctrine 2 for Laravel (NO LONGER MAINTAINED! TryA Doctrine 2 implementation that melts with Laravel 4. DocumentationBegin reading the full documentation here or go to a specific chapter right away.
CaveatsAt the moment Doctrine\migrations version 1.0 is still in alpha. As a result the composer install may require you to change
the If you don't want to affect the stability of the rest of the packages, you can add the following property in your "prefer-stable": true InstallationBegin by installing the package through Composer. Edit your project's
"require": {
"mitchellvanw/laravel-doctrine": "0.5.*"
} Next use Composer to update your project from the the Terminal: php composer.phar update Once the package has been installed you'll need to add the service provider. Open your 'Mitch\LaravelDoctrine\LaravelDoctrineServiceProvider' After This you'll need to add the facade. Open your 'EntityManager' => 'Mitch\LaravelDoctrine\EntityManagerFacade' It's recommended to publish the package configuration. php artisan config:publish mitchellvanw/laravel-doctrine --path=vendor/mitchellvanw/laravel-doctrine/config 2 MinutesThis package uses the Laravel database configuration and thus it works right out of the box. With the Entity Manager facade (or service locator) you can interact with repositories. It might be wise to check out the Doctrine 2 docs to know how it works. The little example below shows how to use the EntityManager in it simplest form. <?php
$user = new User;
$user->setName('Mitchell');
EntityManager::persist($user);
EntityManager::flush(); The <?php
use Doctrine\ORM\Mapping AS ORM;
/**
* @ORM\Entity
* @ORM\Table(name="users")
*/
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;
}
} If you've only used Eloquent and its models this might look bloated or frightening, but it's actually very simple. Let me break the class down. <?php
use Doctrine\ORM\Mapping AS ORM;
/**
* @ORM\Entity
* @ORM\Table(name="users")
*/
class User
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string")
*/
private $name;
} The only thing that's actually important in this With Doctrine 2 you can't interact with database by using the entity LicenseThis package is licensed under the MIT license. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论