This library extracts video IDs from links to hosted videos.
The supported services are:
Install with composer
require visionappscz/video-id-extractor
use VideoIdExtractor\Extractor\VideoIdExtractException;
use VideoIdExtractor\Extractor\YoutubeVideoIdExtractor;
...
$extractor = new YoutubeVideoIdExtractor();
try {
$videoId = $extractor->extract('http://www.youtube.com/watch?v=uWhV5wSyxTI');
} catch (VideoIdExtractException $e) {
die('The supplied link is not valid.)
}