diff --git a/Classes/Service/VimeoService.php b/Classes/Service/VimeoService.php index 8a2e789bc08907e47128e95d650087e4721c4d89..b7eca72b9badd2a2eefe43913697ea5aef918632 100644 --- a/Classes/Service/VimeoService.php +++ b/Classes/Service/VimeoService.php @@ -26,10 +26,24 @@ namespace SGalinski\SgVimeo\Service; +use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; + +// Fallback to the PHAR archive containing the dependency on the vimeo API in case +// this is a legacy installation - not in composer mode +try { + if (!class_exists('\Vimeo\Exceptions\VimeoRequestException')) { + require_once 'phar://' . ExtensionManagementUtility::extPath('sg_vimeo') . + 'Libraries/vimeo-api.phar/autoload.php'; + } +} catch (\Exception $e) { + require_once 'phar://' . ExtensionManagementUtility::extPath('sg_vimeo') . + 'Libraries/vimeo-api.phar/autoload.php'; +} + use Vimeo\Exceptions\VimeoRequestException; use Vimeo\Vimeo; diff --git a/Libraries/vimeo-api.phar b/Libraries/vimeo-api.phar new file mode 100644 index 0000000000000000000000000000000000000000..211d1a6ea446e8727aa328ac8b15367cc6eb1bc7 Binary files /dev/null and b/Libraries/vimeo-api.phar differ diff --git a/README.md b/README.md index 7182ba3ac1fa117b3482d152d36011ef5a7d548a..f0d810c38dc6421e59d791294d8bfe557fec260b 100644 --- a/README.md +++ b/README.md @@ -260,3 +260,50 @@ $services->set(AfterFilterVideosEventListener::class) $services->set(AfterMapCustomThumbnailsEventListener::class) ->tag('event.listener', ['event' => AfterMapCustomThumbnailsEvent::class]); ``` + +## Usage in non-composer mode (Classic, Legacy) + +This extentension has depdendencies from 3rd party sources that we import through composer. Should you have an +installation in legacy mode (non-composer), we need to import these libraries. For this purpose we have the Libraries/ +directory where we put the dependencies as PHAR files. You can check how they are used in Services/VimeoService.php. + +If the dependencies are updated in composer though, we need to regenerate the PHAR file and commit it again. For this we +first pull the new version with composer and then we need to create the PHAR archive by using the following PHP code: + +```php +<?php + +$pharFile = __DIR__ . '/../sg_vimeo.phar'; + +// Remove previous PHAR file if it exists +if (file_exists($pharFile)) { + unlink($pharFile); +} + +$phar = new Phar($pharFile); +$phar->startBuffering(); + +// Add your extension's files +$phar->buildFromDirectory(__DIR__ . '/../sg_vimeo'); + +// Optionally, add files from the vendor directory +$phar->buildFromDirectory(__DIR__ . '/../sg_vimeo'); + +// Optionally, set the default stub to load an entry script +$stub = <<<EOD +<?php +Phar::mapPhar(); +require 'phar://' . __FILE__ . '/Classes/Main.php'; +__HALT_COMPILER(); +EOD; + +$phar->setStub($stub); + +// Stop buffering and save the PHAR file +$phar->stopBuffering(); + +echo "PHAR file created successfully!"; + +``` + +Once it runs it will create the file and we can commit the new version and use it.