PHP code example of rmed19 / simple-behaviors-bundle
1. Go to this page and download the library: Download rmed19/simple-behaviors-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/ */
use Doctrine\ORM\Mapping as ORM;
use Mr\SimpleBehaviorsBundle\Model\SluggableInterface;
use Mr\SimpleBehaviorsBundle\Traits\SluggableEntity;
#[ORM\Entity]
class Article implements SluggableInterface
{
use SluggableEntity;
#[ORM\Column(type: 'string', length: 255)]
private string $title;
public function getTitle(): string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function __toString(): string
{
return $this->title;
}
}
use Doctrine\ORM\Mapping as ORM;
use Mr\SimpleBehaviorsBundle\Model\TimestampableInterface;
use Mr\SimpleBehaviorsBundle\Traits\TimestampableEntity;
#[ORM\Entity]
class Post implements TimestampableInterface
{
use TimestampableEntity;
#[ORM\Column(type: 'string', length: 255)]
private string $content;
public function getContent(): string
{
return $this->content;
}
public function setContent(string $content): self
{
$this->content = $content;
return $this;
}
}
use Symfony\Component\Serializer\SerializerInterface;
$serializedData = $serializer->serialize($article, 'json', ['groups' => ['mr_simple_behaviors:slug:read']]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.