App engine standard env and a storage bucket as TEMP dir

174 views
Skip to first unread message

Ricardo Andrade

unread,
Jan 13, 2018, 12:52:13 PM1/13/18
to Fat-Free Framework
Hi people,

I am trying use Google Cloud (App Engine, standard environment) and I am stuck at here

<?php
require 'vendor/autoload.php';
$f3
= \Base::instance();

$f3
->set('TEMP', 'gs://testbucket');
$f3
->set('DEBUG', 3);
$f3
->set('CACHE', 'memcached');

$f3
->route('GET /',
   
function($f3) {
        $f3
->set('nome','Hello World with template engine');
        echo
\Template::instance()->render('template/layout.html');
   
}
);
$f3
->run();

The result:

Internal Server Error

file_put_contents
(): Exclusive locks may only be set for regular files [vendor/bcosca/fatfree/lib/base.php:2190] Base->error()
[vendor/bcosca/fatfree/lib/base.php:1986] file_put_contents()
[vendor/bcosca/fatfree/lib/base.php:2970] Base->write()
[index.php:12] Preview->render()
[vendor/bcosca/fatfree/lib/base.php:1806] call_user_func_array()
[vendor/bcosca/fatfree/lib/base.php:1627] Base->call()
[index.php:15] Base->run()


Any idea about how fix that?

Thanks in advance,

Ricardo Andrade

richgoldmd

unread,
Jan 13, 2018, 1:01:43 PM1/13/18
to Fat-Free Framework
It appears to be failing when writing the compiled template into gs://testbucket - 
Is there a more ephemeral location you could use for tmp files? These will include compiled templates and file-based cache.

Rayne

unread,
Jan 14, 2018, 7:27:48 AM1/14/18
to Fat-Free Framework
Please try it again with a "/" as path suffix.

Ricardo Andrade

unread,
Jan 14, 2018, 9:57:26 AM1/14/18
to Fat-Free Framework
The local filesystem is ready-only. All references I read points the storage service need to be used...

R.

Ricardo Andrade

unread,
Jan 14, 2018, 9:59:30 AM1/14/18
to Fat-Free Framework
Same error.


Internal Server Error

file_put_contents
(): Exclusive locks may only be set for regular files [vendor/bcosca/fatfree/lib/base.php:2190] Base->error()
[vendor/bcosca/fatfree/lib/base.php:1986] file_put_contents()
[vendor/bcosca/fatfree/lib/base.php:2970] Base->write()
[index.php:12] Preview->render()
[vendor/bcosca/fatfree/lib/base.php:1806] call_user_func_array()
[vendor/bcosca/fatfree/lib/base.php:1627] Base->call()
[index.php:15] Base->run()



ikkez

unread,
Jan 14, 2018, 1:43:12 PM1/14/18
to Fat-Free Framework
hi.
try  $f3->set('TEMP', 'gs://testbucket/');

and maybe this issue can help a bit more https://github.com/bcosca/fatfree/issues/884

Ricardo Andrade

unread,
Jan 14, 2018, 7:30:54 PM1/14/18
to Fat-Free Framework
Did not worked too...

Following the suggestion of https://github.com/bcosca/fatfree/issues/884#issuecomment-153987076 I removed the LOCK_EX| from the base.php at line 1986 and got:

Internal Server Error

require(): gs:// wrapper is disabled in the server configuration by allow_url_include=0 [vendor/bcosca/fatfree/lib/base.php:2190] Base->error()
[vendor/bcosca/fatfree/lib/base.php:2733] Base->{closure}()
[vendor/bcosca/fatfree/lib/base.php:2733] View::sandbox()
[vendor/bcosca/fatfree/lib/base.php:2976] View->sandbox()

ikkez

unread,
Jan 14, 2018, 7:46:04 PM1/14/18
to Fat-Free Framework
ok cool, then have you tried to edit your server configuration now and set allow_url_include=1  ??

Ricardo Andrade

unread,
Jan 16, 2018, 9:14:07 AM1/16/18
to Fat-Free Framework
I added php.ini with

allow_url_include=1

I got

Internal Server Error

require(gs://staging.testnestsite.appspot.com/1lw57utz9r8gg.1eyg24omkrvo0.php): failed to open stream: "\google\appengine\ext\cloud_storage_streams\CloudStorageStreamWrapper::stream_open" call failed [vendor/bcosca/fatfree/lib/base.php:2190] Base->error()

Ricardo Andrade

unread,
Mar 29, 2018, 12:13:06 AM3/29/18
to f3-fra...@googlegroups.com
Solved.

Following the suggestion of https://github.com/bcosca/fatfree/issues/884#issuecomment-153987076 I removed the LOCK_EX| from the base.php at line 1986.

I put in root dir a file named php.ini with

google_app_engine.allow_include_gs_buckets = "bucket-name"

and of course the "bucket name" is the bucket to receive the TEMP files.

And used

$f3->set('TEMP', 'gs://bucket-name');

Thanks people.

Ricardo Andrade

Andrew Quan

unread,
May 16, 2020, 7:47:05 PM5/16/20
to f3-fra...@googlegroups.com

Hi y'all,

Just an update for those of you that now use Google Cloud App Engine Standard Environment PHP 7: https://cloud.google.com/appengine/docs/standard/php7/using-temp-files

Just need to set the following, nothing else (yay):

$f3->set('SEED', 'myapp');
$f3->set('TEMP', '/tmp/');
Reply all
Reply to author
Forward
0 new messages