Download the PHP package lapalabs/youtube-helper without Composer
On this page you can find all versions of the php package lapalabs/youtube-helper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lapalabs/youtube-helper
More information about lapalabs/youtube-helper
Files in lapalabs/youtube-helper
Package youtube-helper
Short Description A tiny package to convenience work with YouTube media resources. Allow to extract ID from resource URL and build valid resource URLs.
License MIT
Homepage https://github.com/LapaLabs/YoutubeHelper
Informations about the package youtube-helper
YoutubeHelper
A tiny package to convenience work with YouTube media resources. Allow to extract ID from resource URL and build valid resource URLs.
Installation
Install package to your project with Composer
:
Usage
Creation
You can easily create valid YouTube resource object:
There are a few valid YouTube resource URLs, supported by this library,
that should be used in YoutubeResource::createFromUrl()
method:
https://youtube.com/watch?v=5qanlirrRWs
https://m.youtube.com/watch?v=5qanlirrRWs
https://www.youtube.com/watch?v=5qanlirrRWs
https://www.youtube.com/embed/5qanlirrRWs
https://youtu.be/5qanlirrRWs
Advanced usage
After resource was successfully created you get access to a bunch of useful methods:
You can get array of valid YouTube resource URLs which could used in createFromUrl
method:
To check whether YouTube resource ID or host is valid use follow methods:
You can easily get HTML code to embed YouTube resource on your page:
The passed attributes to
buildEmbedCode()
methods applies for current embed HTML code only. To change default attributes globally for specific resource you should pass an array of attributes tosetAttributes()
method. To get current default HTML attributes of specific resource usegetAttributes()
method.
There are a few attributes by default:
NOTE: The
src
attribute is only required for building embed HTML code and will be injected automatically by callingbuildEmbedUrl()
method behind the scenes. So every givensrc
value tobuildEmbedCode()
orsetAttributes()
will be ignoring and replacing with correct URL for current resource. You could give it like in example above to point its position in HTML code.
Links
Feel free to create an Issue or Pull Request if you find a bug or just want to propose improvement suggestion.
Move UP