Skip to content
Snippets Groups Projects
Commit 6e007887 authored by Georgi's avatar Georgi
Browse files

Merge branch 'feature_phar_composer_mode' into 'master'

Add PHAR archive as a fallback for the dependencies

See merge request !11
parents 00d2bf96 7982e3b2
No related branches found
No related tags found
1 merge request!11Add PHAR archive as a fallback for the dependencies
......@@ -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;
......
File added
......@@ -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.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment