1. Go to this page and download the library: Download becklyn/video-platforms 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/ */
becklyn / video-platforms example snippets
use Becklyn\VideoPlatforms\Parser\VideoUrlParser;
function parse (VideoUrlParser $parser, string $videoUrl)
{
$video = $parser->parse($videoUrl);
}
use Becklyn\VideoPlatforms\Video\Video;
$video = new Video("youtube", "123");
assert("youtube@123" === $video->serialize());
use Becklyn\VideoPlatforms\Video\Video;
$serialized = "youtube@123";
$video = Video::unserialize($serialized);
assert("youtube" === $video->getPlatform());
assert("123" === $video->getId());
// will be autogenerate
assert("youtube@123" === $video->getUrl());
use Becklyn\VideoPlatforms\Validation\Constraint\VideoUrl;
use Becklyn\VideoPlatforms\Video\Video;
class MyEntity
{
/**
* @ORM\Column(name="video", type="json")
*
* @VideoUrl(platforms={"vimeo"})
* @Assert\NotNull()
*/
private ?array $video = null;
/**
*/
public function getVideo () : ?Video
{
return Video::createFromArray($this->video);
}
/**
*/
public function setVideoUrl (?Video $video) : void
{
$this->video = null !== $video
? $video->toArray()
: null;
}
}
use Becklyn\VideoPlatforms\Form\Type\VideoUrlType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class MyForm extends AbstractType
{
/**
* @inheritDoc
*/
public function buildForm (FormBuilderInterface $builder, array $options) : void
{
parent::buildForm($builder, $options);
$builder
->add("video", VideoUrlType::class, [
"label" => "video.label",
"
/**
* @VideoUrl()
*/
/**
* @VideoUrl(platforms={"vimeo"})
*/
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.