PHP code example of andanteproject / timestampable-bundle
1. Go to this page and download the library: Download andanteproject/timestampable-bundle 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/ */
andanteproject / timestampable-bundle example snippets
namespace App\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Andante\TimestampableBundle\Timestampable\TimestampableInterface;
use Andante\TimestampableBundle\Timestampable\TimestampableTrait;
#[ORM\Entity]
class Article implements TimestampableInterface // <-- implement this
{
use TimestampableTrait; // <-- add this
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: Types::INTEGER)]
private ?int $id = null;
#[ORM\Column(type: Types::STRING)]
private string $title;
public function __construct(string $title)
{
$this->title = $title;
}
// ...
// Other properties and methods ...
// ...
}
namespace App\Entity;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Andante\TimestampableBundle\Timestampable\TimestampableInterface;
#[ORM\Entity]
class Article implements TimestampableInterface // <-- implement this
{
// No trait needed
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: Types::INTEGER)]
private ?int $id = null;
#[ORM\Column(type: Types::STRING)]
private string $title;
// DO NOT use ORM attributes to map these properties. See the configuration section for details.
private ?\DateTimeImmutable $createdAt = null;
private ?\DateTimeImmutable $updatedAt = null;
public function __construct(string $title)
{
$this->title = $title;
}
public function setCreatedAt(\DateTimeImmutable $dateTime): void
{
$this->createdAt = $dateTime;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setUpdatedAt(\DateTimeImmutable $dateTime): void
{
$this->updatedAt = $dateTime;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.