PHP code example of byng-systems / pimcore-doctrine-library
1. Go to this page and download the library: Download byng-systems/pimcore-doctrine-library library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
byng-systems / pimcore-doctrine-library example snippets
namespace Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="products")
**/
class Product
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue
*/
protected $id;
/**
* @ORM\Column(type="string")
*/
protected $name;
public function getId()
{
return $this->id;
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
return $this;
}
}
namespace Entity\Repository;
use Byng\Pimcore\Doctrine\AbstractRepository;
class ProductRepository extends AbstractRepository
{
const ENTITY_CLASS = "Entity\\Product";
/**
*
* @return string
*/
protected function getEntityClass()
{
return static::ENTITY_CLASS;
}
}
use Entity\Repository\ProductRepository;
use Byng\Pimcore\Doctrine\Setup;
use Entity\Product;
$product = new Product();
$product->setName("Test");
$repository = new ProductRepository(Setup::getEntityManager());
$repository->save($product);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.