Bref: "local" command broken

Created on 12 Jun 2018  路  5Comments  路  Source: brefphp/bref

Hi,

I've just updated bref to version 0.2.13 with opcache support added by #14.

And now the bref local command isn't working anymore.

Before the update, the handler.js ran the php command without any argument. It used to work fine but since you've added a php.ini defining a specific extensions directory, my local binary fail to load extensions, including opcache.so.

I am wondering if I'm using the local command the right way or if I'm missing something?

Or is there really an issue here?

Here is an output example:

$ vendor/bin/bref local
Invoking the lambda
 7/7 [鈻戔枒鈻戔枒鈻戔枒鈻戔枒鈻戔枒鈻戔枒鈻戔枒鈻戔枒鈻戔枒鈻戔枒鈻戔枒鈻戔枒鈻戔枒鈻戔枒] 20 secs

In Process.php line 223:

  The command "serverless invoke local -f 'main'" failed.                                                                                                                                                                                    

  Exit Code: 1(General error)                                                                                                                                                                                                                

  Working directory: .bref/output                                                                                                                                                                                                            

  Output:                                                                                                                                                                                                                                    
  ================                                                                                                                                                                                                                           
  [STDERR] PHP Warning:  Failed loading Zend extension 'opcache.so' (tried: /var/task/.bref/bin/ext/opcache.so (/var/task/.bref/bin/ext/opcache.so: cannot open shared object file: No such file or directory), /var/task/.bref/bin/ext/opc  
  ache.so.so (/var/task/.bref/bin/ext/opcache.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
bug

All 5 comments

Oh right! I need to add tests for this.

I'm working on that today.

Please try 0.2.14 and let me know!

It works! Thank you for the quick fix.

So you've added an env variable allowing different behaviors according to whether it's defined or not.

Is there plan to add more different behaviors according to this variable?

I'm thinking about loading different serverless.yml for exemple, as the source for my env variables might not be the same in production and local env. And maybe a different .bref.yml as the build might also be different according to the current environment.

We could add more behavior.

However for environment variables I think it might be better to use something like .env (DotEnv) files when running locally. That will avoid reinventing the wheel.

But also the more I think about it, the more I think it doesn't make a lot of sense to run the lambda in .bref/output. After all the dev environment is setup correctly, we could simply run the lambda in the project directory, that would also be similar to CLI and HTTP invocations:

  • HTTP: run using php -S 127.0.0.1 bref.php
  • CLI: run using php bref.php <arguments>
  • direct invocation: run using ?

And that way the dev environment is always the same, no need to be locked-in Bref specific stuff.

I have an idea, I'll open a pull request to discuss that.

I've opened #22 with that idea.

Was this page helpful?
0 / 5 - 0 ratings