Getting below error after runnnig command "dev_appserver.py C:\Newfolder"
google.appengine.tools.devappserver2.errors.InvalidAppConfigError: In env: flex, only the following runtimes are allowed: ('python-compat', 'java', 'java7', 'go', 'custom')
I have installed php version 8.0.6 , and i'm trying to run a sample php application on localhost using google app engine's sdk.
my app.yaml looks like this:
runtime: php8
env: flex
runtime_config:
document_root: Newfolder
I tried putting runtime as custom , php72, php55 and even php80(since my php version is 8.0.6)
but still am getting the same error
referring this link https://cloud.google.com/appengine/docs/standard/php/tools/using-local-server
If you want to use php in flex environment your app.yaml needs to look something similar to this:
runtime: php
env: flex
runtime_config:
document_root: web
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10
The php version that app engine flex will use is the default PHP 7.3, but if you want to use another version you can specify it in the composer.json as this link says
Related
I have an App (PHP 7.4) running on Google AppEngine Standard. Now i have created
a new Project inside CloudConsole wih same settings and want to deploy
this App to the new generated Project for testreason.
gcloud app deploy app.yaml --project=testapp-2022-08-14
But i am getting this error:
Fatal error: Unknown: Failed opening required '/srv/vendor/google/cloud-error-reporting/src/prepend.php' (include_path='.:/layers/google.php.runtime/php/lib/php') in Unknown on line 0
To activate the Cloud-Error-Reporting i followed this Documentation:
CloudErrorrEPORTING
my php.ini
auto_prepend_file = '/srv/vendor/google/cloud-error-reporting/src/prepend.php'
session.gc_maxlifetime = 259200
opcache.memory_consumption = 128
my app.yaml
runtime: php74
instance_class: F1
entrypoint: serve bootstrap.php
handlers:
...
env_variables:
...
runtime_config:
document_root: .
automatic_scaling:
max_instances: 20
any help is welcome
Using AppEngine's standard configuration with PHP 7.4 runtime, we encountered the same issue recently, and the value set for auto_prepend_file
registering the library in php.ini in the standard setting no longer works. As we checked the sample repository, we discovered that they suggested registering error handlers manually as a workaround if php.ini cannot be accessed.
In our case, registering the error handler manually, resolved the issue.
# This works for files in the root of your project. Adjust __DIR__ accordingly.
require_once __DIR__ . '/vendor/google/cloud-error-reporting/src/prepend.php';
Take a look at the sample repository and verify that your configuration is set up correctly as well.
https://github.com/GoogleCloudPlatform/php-docs-samples/tree/6609166f71b1049f45360480963c2327b00b7959/appengine/standard
Hope this helps!
When using Intervention\Image in laravel on lambda
The following error has occurred.
By the way, it works in the local environment.
I have to add gd.
[2021-08-17 10:37:18] DEV.ERROR: GD Library extension not available with this PHP installation.
{"exception":"[object] (Intervention\Image\Exception\NotSupportedException(code: 0):
GD Library extension not available with this PHP installation.
at /var/task/vendor/intervention/image/src/Intervention/Image/Gd/Driver.php:19)
What I looked up
https://bref.sh/docs/environment/php.html#extensions
https://github.com/brefphp/extra-php-extensions
Deployment method
We are deploying to lambda using the sls command.
sls deploy --stage dev
Based on the investigation, the following is implemented
composer require bref/extra-php-extensions
Added below
serverless.yml
plugins:
- ./vendor/bref/bref
- ./vendor/bref/extra-php-extensions #add
functions:
# This function runs the Laravel website/API
web:
image:
name: laravel
events:
- httpApi: '*'
# This function lets us run artisan commands in Lambda
artisan:
handler: artisan
timeout: 120 # in seconds
layers:
- ${bref:layer.php-80}
- ${bref:layer.console}
- ${bref-extra:gd-php-80} #add
Even if the above settings are added and deployed, they are not updated. .. why?
enviroment
Laravel Framework 8.33.1
PHP 7.4.3
bref
serverless
I'm sorry if English is strange.
Put the layers into web "tag".
plugins:
- ./vendor/bref/bref
- ./vendor/bref/extra-php-extensions #add
functions:
# This function runs the Laravel website/API
web:
image:
name: laravel
layers:
- ${bref-extra:gd-php-80} #add
events:
- httpApi: '*'
# This function lets us run artisan commands in Lambda
artisan:
handler: artisan
timeout: 120 # in seconds
layers:
- ${bref:layer.php-80}
- ${bref:layer.console}
Then add the folder php/conf.d inside put a file with extension .ini. For example php.ini. In it just put:
extension=gd
If you've worked with Laravel and Lando together, you probably know that Lando gives you its own artisan shortcut. So instead of having to run lando php artisan ..., you can run lando artisan ....
However, when I do that, I get this error:
Could not open input file: /app/./../artisan
This forces me to have to run lando php artisan to run any artisan commands, and that does work fine. So far, this is all that's going wrong with my project in Lando. Everything else is running smoothly.
Here's what my lando config looks like:
name: laravel-project
recipe: laravel
config:
php: '7.4'
composer_version: '2.0.12'
database: mysql:8.0
services:
appserver:
webroot: public
xdebug: true
config:
php: .vscode/php.ini
node:
type: node:14
tooling:
node:
service: node
yarn:
service: node
Also, this does look a bit different from Lando's sample config on their website. This is because I was trying to configure xdebug according to their "Using Lando with VSCode" instructions (see Lando rc.2+ version).
Appreciate any help figuring this weird issue out. It's not debilitating, but it does get in the way when I forget the workaround.
Other notes:
"webroot" is set to "public" because that's where the public-facing directory is for a Laravel app. The example Lando config for Laravel has this part wrong and it causes the project root to be visible to the browser.
I got it working. I moved the webroot key back under the top-level config. Not sure what the difference is, but as long as it works... I guess the only thing I really need to specify in the appserver service is the Xdebug settings.
name: laravel-project
recipe: laravel
config:
php: '7.4'
composer_version: '2.0.12'
webroot: public
database: mysql:8.0
services:
appserver:
xdebug: true
config:
php: .vscode/php.ini
node:
type: node:14
tooling:
node:
service: node
yarn:
service: node
I'm not able to use curl_lite as I need certificate. Curl works fine in production but not through the Google App Engine Dev server.
Here's my php.ini:
extension = "curl.so"
google_app_engine.enable_functions = "phpversion, phpinfo, php_sapi_name, php_uname, getmypid"
google_app_engine.allow_include_gs_buckets = "df_sabre_queue"
allow_url_include = 1
The error message thrown is:
Fatal error: Call to undefined function App\SomeClass\curl_init() in C:\Users\Egroeg\Code\SampleApp\app\Sabre\Request.php on line 52
App.yaml is:
application: sample-app
version: 1
runtime: php55
api_version: 1
handlers:
- url: /favicon\.ico
static_files: public/favicon.ico
upload: public/favicon\.ico
- url: /.*
script: public/index.php
skip_files:
- ^(.*/)?#.*#$
- ^(.*/)?.*~$
- ^(.*/)?.*\.py[co]$
- ^(.*/)?.*/RCS/.*$
- ^(.*/)?\.(?!env).*$
- ^(.*/)?node_modules.*$
- ^(.*/)?_ide_helper\.php$
- ^(.*/)?\.DS_Store$
extension_loaded('curl') returns false.
If your development environment is windows the extensions have slightly different names (to be consistent with the documentation you would find on php.net)
For windows, change the php.ini file to
extension = "php_curl.dll"
Not that in production we accept either php_curl.dll or curl.so to load the curl extension so you do not need to change the php.ini file before pushing your app.
I'm new to Google App Engine and having troubling understanding their error messages.
I'm using Google App Engine Launcher (on Win XP).
When I press Deploy (and then sign-in) I get this error message.
\pythonw.exe', '-u', 'C:\Program
Files\Google\google_appengine\appcfg.py', '--no_cookies',
u'--email=by#onetel.com', '--passin', 'update', 'C:\Documents and
Settings\Barry\My Documents\test\high-winter-668']" Usage:
appcfg.py [options] update | [file, ...]
appcfg.py: error: Error parsing C:\Documents and Settings\Barry\My
Documents\test\high-winter-668\app.yaml: Unable to assign value
'http://high-winter-668.appspot.com/' to attribute 'application':
Value 'http://high-winter-668.appspot.com/' for application does not
match expression
'^(?:(?:[a-z\d-]{1,100}\~)?(?:(?!-)[a-z\d-.]{1,100}:)?(?!-)[a-z\d-]{0,99}[a-z\d])$'
in "C:\Documents and Settings\Barry\My
Documents\test\high-winter-668\app.yaml", line 1, column 14.
2014-08-15 17:09:39 (Process exited with code 2)
Can someone tell me what this means please?
My app.yaml file contains:
application: http://high-winter-668.appspot.com/
version: 1
runtime: php
api_version: 1
handlers:
- url: /.*
script: high-winter-668.php
At https://appengine.google.com/
my "Application" and "Title" both say "high-winter-668"
And in my local application folder C:\Documents and Settings....\high-winter-668\
I have two files:
app.yaml and high-winter-668.php
Thanks
I use just the app name alone:
application: high-winter-668
version: 1
runtime: php
api_version: 1
handlers:
- url: /.*
script: high-winter-668.php
This:
^(?:(?:[a-z\d-]{1,100}\~)?(?:(?!-)[a-z\d-.]{1,100}:)?(?!-)[a-z\d-]{0,99}[a-z\d])$
is a Reg-Ex search pattern
To add more about app name:
Only lowercase, digits and '-' are allowed and the app name cannot be
more than 100 characters long.