Skip to content

Commit

Permalink
Use our own PHP binary
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Feb 16, 2018
1 parent d2ff0bc commit cb7fbc5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
15 changes: 7 additions & 8 deletions phplambda
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,13 @@ $app->command('deploy', function (SymfonyStyle $io) {
return 1;
}
// TODO check if there are uncommitted changes in the directory, warn the user that these will not be deployed
// TODO replace with rsync
$commandRunner->run('cd .phplambda && git clone .. .');

$io->writeln('Installing PHP in the `bin/` directory');
$fs->mkdir('.phplambda/bin');
if (!$fs->exists('.phplambda/bin/php')) {
$commandRunner->run('curl -sSL https://lambci.s3.amazonaws.com/binaries/libtidy-0.99.tgz | tar -xz -C .phplambda/bin');
$commandRunner->run('curl -sSL https://lambci.s3.amazonaws.com/binaries/libmcrypt-4.4.8.tgz | tar -xz -C .phplambda/bin');
$commandRunner->run('curl -sSL https://lambci.s3.amazonaws.com/binaries/php-7.1.2.tgz | tar -xz -C .phplambda/bin');
$fs->rename('.phplambda/bin/7.1.2', '.phplambda/bin/php');
$fs->remove('.phplambda/bin/php/etc/conf.d/xdebug.ini'); // disable xdebug
$io->writeln('Installing PHP in the `.phplambda/bin/` directory');
$fs->mkdir('.phplambda/.phplambda/bin');
if (!$fs->exists('.phplambda/.phplambda/bin/php')) {
$commandRunner->run('curl -sSL https://s3.amazonaws.com/bref-php/bin/php-7.2.2.tar.gz | tar -xz -C .phplambda/.phplambda/bin');
}

$io->writeln('Installing `handler.js`');
Expand All @@ -70,6 +67,8 @@ $app->command('deploy', function (SymfonyStyle $io) {

// TODO check there is a lambda.php file

// TODO edit serverless.yml to auto-add .phplambda

// Run build hooks defined in .phplambda.yml
if ($fs->exists('.phplambda/.phplambda.yml')) {
$config = Yaml::parse(file_get_contents('.phplambda/.phplambda.yml'));
Expand Down
2 changes: 1 addition & 1 deletion serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package:
include:
- handler.js
- lambda.php
- 'bin/**'
- '.phplambda/**'
- 'src/**'
- 'vendor/**'

Expand Down
7 changes: 1 addition & 6 deletions template/handler.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
process.env['PATH'] = process.env['PATH']
+ ':' + process.env['LAMBDA_TASK_ROOT'] + '/bin/php/bin'; // for PHP

// It seems to be necessary for lambci's PHP to work
// @see https://github.com/lambci/lambci/blob/c2a81276b2dcd70fae093f68cddcd42bf086ed8f/actions/build.js#L266-L269
process.env['LD_LIBRARY_PATH'] = process.env['LD_LIBRARY_PATH']
+ ':' + process.env['LAMBDA_TASK_ROOT'] + '/bin/usr/lib64';
+ ':' + process.env['LAMBDA_TASK_ROOT'] + '/.phplambda/bin'; // for PHP

const spawn = require('child_process').spawn;
const fs = require('fs');
Expand Down
2 changes: 1 addition & 1 deletion template/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package:
include:
- handler.js
- lambda.php
- 'bin/**'
- '.phplambda/**'
- 'src/**'
- 'vendor/**'

Expand Down

0 comments on commit cb7fbc5

Please sign in to comment.