diff --git a/.gitattributes b/.gitattributes
index abb424b7..543578eb 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,6 +1,12 @@
+export/ export-ignore
layers/ export-ignore
+src/ export-ignore
.gitattributes export-ignore
.gitignore export-ignore
+.phpcs.xml.dist export-ignore
+.prettyci.composer.json export-ignore
.travis.yml export-ignore
+bref-extra export-ignore
+bchecksums.json export-ignore
Makefile export-ignore
diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist
index c80af217..c30132ab 100644
--- a/.phpcs.xml.dist
+++ b/.phpcs.xml.dist
@@ -7,13 +7,8 @@
- bref
+ bref-extra
src
- tests
- tests/Bridge/Symfony/var
- tests/Bridge/Symfony/cache
- tests/Bridge/Symfony/logs
- tests/Bridge/Laravel/bootstrap/cache
diff --git a/.travis.yml b/.travis.yml
index 8d647930..464c73d2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,4 +1,4 @@
-language: php
+language: minimal
notifications:
email:
@@ -8,16 +8,31 @@ services:
- docker
env:
- - LAYER=amqp PHP=72
- - LAYER=amqp PHP=73
- - LAYER=amqp PHP=74
- - LAYER=blackfire PHP=72
- - LAYER=blackfire PHP=73
- - LAYER=blackfire PHP=74
- - LAYER=xdebug PHP=72
- - LAYER=xdebug PHP=73
- - LAYER=xdebug PHP=74
+ - LAYER=amqp PHP="72 73 74"
+ - LAYER=blackfire PHP="72 73 74"
+ - LAYER=xdebug PHP="72 73 74"
+
+before_install:
+ - |
+ # tfold is a helper to create folded reports (From Symfony)
+ tfold () {
+ local title="$1"
+ local fold=$(echo $title | sed -r 's/[^-_A-Za-z0-9]+/./g')
+ shift
+ echo -e "travis_fold:start:$fold"
+ echo -e "\\e[1;34m$title\\e[0m"
+ bash -xc "$*" 2>&1
+ local ok=$?
+ (exit $ok) &&
+ echo -e "\\e[32mOK\\e[0m $title\\n\\ntravis_fold:end:$fold" ||
+ echo -e "\\e[41mKO\\e[0m $title\\n"
+ (exit $ok)
+ }
+ export -f tfold
script:
- cd layers/$LAYER
- - docker build --build-arg PHP_VERSION=$PHP .
+ - |
+ for php_version in $PHP; do
+ tfold "Build $php_version" docker build --build-arg PHP_VERSION=${php_version} .
+ done
diff --git a/Readme.md b/Readme.md
index 9b691d74..02494bfd 100644
--- a/Readme.md
+++ b/Readme.md
@@ -17,7 +17,7 @@ provider:
plugins:
- ./vendor/bref/bref
- - ./vendor/bref/extra-layers # <--- Add the extra Serverless plugin
+ - ./vendor/bref/extra-layers # <----- Add the extra Serverless plugin
functions:
console:
@@ -28,7 +28,7 @@ functions:
- ${bref:layer.console}
```
-```
+```ini
;php/conf.d/php.ini
extension=/opt/bref-extra/amqp.so
```
@@ -45,7 +45,6 @@ extension=/opt/bref-extra/amqp.so
```
make publish
-make list
git add checksums.json layers.json
git commit -m "New version of layers"
git push
diff --git a/composer.json b/composer.json
index 65f751dc..af6c4405 100644
--- a/composer.json
+++ b/composer.json
@@ -1,5 +1,6 @@
{
- "name": "bref/extra-layers",
+ "name": "bref/extra-php-extensions",
+ "description": "Extra PHP extensions for your lambda application.",
"type": "library",
"require-dev": {
"symfony/process": "^5.0",
diff --git a/src/Application.php b/src/Application.php
index e86a6be3..206a0c12 100644
--- a/src/Application.php
+++ b/src/Application.php
@@ -1,33 +1,32 @@
-addDefinitions([
'project_dir' => $projectDir,
@@ -50,4 +49,4 @@ protected function createContainer()
return $builder->build();
}
-}
\ No newline at end of file
+}
diff --git a/src/Aws/LayerProvider.php b/src/Aws/LayerProvider.php
index 7101c628..8d88c2eb 100644
--- a/src/Aws/LayerProvider.php
+++ b/src/Aws/LayerProvider.php
@@ -1,29 +1,23 @@
-
*/
class LayerProvider
{
+ /** @var string */
private $awsId;
- /**
- * @var array
- */
+ /** @var array */
private $layerNames;
/**
- * @param array $layerNames the name of the layers to list.
- * @param string $awsId The account id
+ * @param array $layerNames the name of the layers to list.
+ * @param string $awsId The account id
*/
public function __construct(array $layerNames, string $awsId)
{
@@ -50,7 +44,7 @@ public function listLayers(string $selectedRegion): array
// Wait on all of the requests to complete. Throws a ConnectException
// if any of the requests fail
- $results = \GuzzleHttp\Promise\unwrap($promises);
+ $results = unwrap($promises);
$layers = [];
foreach ($results as $layerName => $result) {
@@ -61,6 +55,4 @@ public function listLayers(string $selectedRegion): array
return $layers;
}
-
-
-}
\ No newline at end of file
+}
diff --git a/src/Aws/LayerPublisher.php b/src/Aws/LayerPublisher.php
index 26c80b37..c008b2c3 100644
--- a/src/Aws/LayerPublisher.php
+++ b/src/Aws/LayerPublisher.php
@@ -1,6 +1,4 @@
-awsProfile = $awsProfile;
@@ -24,8 +16,8 @@ public function __construct(?string $awsProfile)
/**
- * @param array $layers Layer name and layer zip file path.
- * @param array $regions
+ * @param array $layers Layer name and layer zip file path.
+ * @param array $regions
*/
public function publishLayers(array $layers, array $regions): void
{
@@ -38,7 +30,6 @@ public function publishLayers(array $layers, array $regions): void
}
$this->finishProcesses($publishingProcesses);
-
// Add public permissions on the layers
/** @var Process[] $permissionProcesses */
$permissionProcesses = [];
@@ -55,9 +46,7 @@ public function publishLayers(array $layers, array $regions): void
/**
* @param string $region The AWS region to publish the layer to
- * @param string $layerName
- * @param string $file The absolute file path to the layer
- * @return Process
+ * @param string $file The absolute file path to the layer
*/
private function publishSingleLayer(string $region, string $layerName, string $file): Process
{
@@ -74,7 +63,7 @@ private function publishSingleLayer(string $region, string $layerName, string $f
'--license-info',
'MIT',
'--zip-file',
- 'fileb://'.$file,
+ 'fileb://' . $file,
'--compatible-runtimes',
'provided',
// Output the version so that we can fetch it and use it
@@ -122,10 +111,7 @@ private function finishProcesses(array $processes): void
}
/**
- * @param string $region
* @param string $layer name
- * @param string $layerVersion
- * @return Process
*/
private function addPublicLayerPermissions(string $region, string $layer, string $layerVersion): Process
{
@@ -157,7 +143,4 @@ private function addPublicLayerPermissions(string $region, string $layer, string
return $process;
}
-
-
-
-}
\ No newline at end of file
+}
diff --git a/src/Command/HelpCommand.php b/src/Command/HelpCommand.php
index 5676631c..48f4a9a0 100644
--- a/src/Command/HelpCommand.php
+++ b/src/Command/HelpCommand.php
@@ -1,21 +1,16 @@
-writeln('With this small application you may publish new layers and list existing ones in layer.json');
$output->writeln('You may specify the following environment variables: AWS_ID, AWS_PROFILE');
return 0;
}
-}
\ No newline at end of file
+}
diff --git a/src/Command/ListCommand.php b/src/Command/ListCommand.php
index 80e96a36..3028e362 100644
--- a/src/Command/ListCommand.php
+++ b/src/Command/ListCommand.php
@@ -1,6 +1,4 @@
-regionProvider = $regionProvider;
}
- public function __invoke(OutputInterface $output)
+ public function __invoke(OutputInterface $output): int
{
$export = [];
foreach ($this->regionProvider->getAll() as $region) {
@@ -52,4 +44,4 @@ public function __invoke(OutputInterface $output)
return 0;
}
-}
\ No newline at end of file
+}
diff --git a/src/Command/PublishCommand.php b/src/Command/PublishCommand.php
index 46a08a94..2db418d6 100644
--- a/src/Command/PublishCommand.php
+++ b/src/Command/PublishCommand.php
@@ -1,6 +1,4 @@
-regionProvider = $regionProvider;
}
- public function __invoke(OutputInterface $output)
+ public function __invoke(OutputInterface $output): int
{
- $checksums = file_get_contents($this->projectDir.'/checksums.json');
+ $checksums = file_get_contents($this->projectDir . '/checksums.json');
$discoveredChecksums = [];
$layers = [];
- $finder = new Finder();
- $finder->in($this->projectDir.'/export')
- ->name('layer-*');
+ $finder = new Finder;
+ $finder->in($this->projectDir . '/export')->name('layer-*');
foreach ($finder->files() as $file) {
/** @var \SplFileInfo $file */
$layerFile = $file->getRealPath();
$layerName = substr($file->getFilenameWithoutExtension(), 6);
$md5 = md5_file($layerFile);
$discoveredChecksums[$layerName] = $md5;
- if (false === strstr($checksums, $md5)) {
+ if (strstr($checksums, $md5) === false) {
// This layer is new.
$layers[$layerName] = $layerFile;
}
@@ -58,18 +49,18 @@ public function __invoke(OutputInterface $output)
try {
$this->publisher->publishLayers($layers, $this->regionProvider->getAll());
- }catch(\Exception $e) {
+ } catch (\Throwable $e) {
// TODO write output.
exit(1);
}
ksort($discoveredChecksums);
// Dump checksums
- file_put_contents($this->projectDir.'/checksums.json', json_encode($discoveredChecksums, \JSON_PRETTY_PRINT));
+ file_put_contents($this->projectDir . '/checksums.json', json_encode($discoveredChecksums, \JSON_PRETTY_PRINT));
$output->writeln('Done');
$output->writeln('Remember to commit and push changes to ./checksums.json');
return 0;
}
-}
\ No newline at end of file
+}
diff --git a/src/Service/RegionProvider.php b/src/Service/RegionProvider.php
index 583f9659..20463d80 100644
--- a/src/Service/RegionProvider.php
+++ b/src/Service/RegionProvider.php
@@ -1,15 +1,9 @@
-
*/
class RegionProvider
{