Giter VIP home page Giter VIP logo

googlecloudplatform / php-docs-samples Goto Github PK

View Code? Open in Web Editor NEW
944.0 156.0 1.0K 22.59 MB

A collection of samples that demonstrate how to call Google Cloud services from PHP.

Home Page: http://cloud.google.com/php

License: Apache License 2.0

PHP 97.92% HTML 0.09% JavaScript 0.07% Shell 0.44% Dockerfile 0.18% Twig 0.53% M4 0.01% C 0.06% Procfile 0.01% CSS 0.01% Blade 0.67%
samples

php-docs-samples's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-docs-samples's Issues

Bigquery test fails on jenkins

There was 1 error:

1) utilTest::testListDatasets
Object of class Google_Service_Bigquery_DatasetListDatasets could not be converted to string

<https://jenkins.on2flixcloud.tv/job/php-docs-samples/ws/bigquery/api/test/utilTest.php>:124

FAILURES!

Memcache not found

After installing and while running vendor/bin/wp server I am getting this error on MacOSX in standard mode:

Class 'Memcache' not found in my-wordpress-project/wordpress/wp-content/object-cache.php on line 425

The file object-cache.php resides in multiple locations. That looks a bit weird.

Drupal instructions throw an error

It's about the last part of the README.

~/bin/drupal config:edit                                       
  [InvalidArgumentException]                                
  There are no commands defined in the "config" namespace.  

Also, the integration test on our jenkins fails with:

+ /workspace/php-docs-samples/managed_vms/drupal8/tests/drupal cache:rebuild all
  [InvalidArgumentException]                               
  There are no commands defined in the "cache" namespace. 

Do I miss something?

[Wordpress] CloudSQL access not possible

Hi everyone!

I just try to install a bare WordPress and followed the README.md steps.
The CloudSQL instance is running and I can access it locally via the cloudsql-proxy.

After fixing the app.yaml to use the flexible AppEngine setting to

env: flex

and wp-config.php

    /** Production environment */                                                                                                
    define('DB_HOST', ':/cloudsql/$PROJECT_ID:us-east1:$DBNAME');                                                         
    /** The name of the database for WordPress */                                                                                
    define('DB_NAME', '$DBNAME');                                                                                              
    /** MySQL database username */                                                                                               
    define('DB_USER', '$DBUSERNAME');                                                                                              
    /** MySQL database password */                                                                                               
    //define('DB_PASSWORD', '$DBPASSWORD'); 

deployment works but opening any page in Wordpress ends (after a long time) in the following error:

Warning: mysqli_real_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /app/wordpress/wp-includes/wp-db.php on line 1538 Warning: mysqli_real_connect(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known in /app/wordpress/wp-includes/wp-db.php on line 1538 Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /app/wordpress/wp-includes/wp-db.php on line 1568 Notice: mysql_connect(): SQL safe mode in effect - ignoring host/user/password information in /app/wordpress/wp-includes/wp-db.php on line 1568 Warning: mysql_connect(): No such file or directory in /app/wordpress/wp-includes/wp-db.php on line 1568

Error establishing a database connection

Interestingly, using mysql-client on the command-line to connect via the socket works.

mysql -S /cloudsql/$PROJECTID\:us-east1\:$DBNAME -u $DBUSER -p$DBPASSWORD

[App Engine] Update README prerequisites

Memcache and PHP 5.5 should be added as prerequisites or mentioned in the README since they are need for running WordPress Standard Environment locally.

EDIT: I currently have not looked into documenting the prerequisites for the Flexible Environment.

Google App Engine PHP Wordpress Common Errors

Below are the common errors I keep experiencing when trying to setup Wordpress on GoogleCloud.

Version

  • State which platform should work best and which PHP Version is best either PHP5 or PHP7.
  • State which memcached plugin is required, list the url to download the memcached plugin. \
  • State whether we should use flexible or standard version.

Changing the port

Port Changing
It is very difficult to change from localhost:8080 to localhost:8081, any ideas showing how to do that would be greatful especially when running multiple, wordpress sites.

PHP Executable Path

How to change the path
When installation is complete, Wordpress asks, to change the PHP Executable path, any ideas showing how to do this would be greatful.

Wordpress Continous Reload

After setting up the site, the site keeps reloading and no error shows, whats going on.
Nothing is showing up in the error logs pages.

Vendor Folder not Created

When setting up, the vendor folder is not created and the site can't run without the vendor folder.

Deprecate the following Github

@tmatsuo @bshaffer
https://github.com/GoogleCloudPlatform/appengine-php-wordpress-starter-project, from your webpage, use that one as the official one, since there are now multiple ones. This will avoid the confusion.

Requirments by Platform

OpenSSL
MAMP PRO
Memcache

Update composer.lock to cloud-tools to v6.0

This can be done by running the following bash command:

find . -name composer.lock -not -path "*/vendor/*" \
    -exec sh -c 'pushd "${0%/*}" && composer update && popd' {} \;

Local Plugin management fails

I have a wordpress setup running in the Standard Environment.
Execution locally with CloudSQL also works.

But performing Plugin maintenance via wp always fails:

# vendor/bin/wp plugins list --path=wordpress
PHP Warning:  require_once(google/appengine/api/urlfetch_service_pb.php): failed to open stream: No such file or directory in /Users/Sebastian.Just/development/workspaces/gcp/wordpress2/wordpress/wp-content/plugins/google-app-engine/modules/urlfetch.php on line 72
Warning: require_once(google/appengine/api/urlfetch_service_pb.php): failed to open stream: No such file or directory in /Users/Sebastian.Just/development/workspaces/gcp/wordpress2/wordpress/wp-content/plugins/google-app-engine/modules/urlfetch.php on line 72
PHP Fatal error:  require_once(): Failed opening required 'google/appengine/api/urlfetch_service_pb.php' (include_path='.:') in /Users/Sebastian.Just/development/workspaces/gcp/wordpress2/wordpress/wp-content/plugins/google-app-engine/modules/urlfetch.php on line 72
Fatal error: require_once(): Failed opening required 'google/appengine/api/urlfetch_service_pb.php' (include_path='.:') in /Users/Sebastian.Just/development/workspaces/gcp/wordpress2/wordpress/wp-content/plugins/google-app-engine/modules/urlfetch.php on line 72 

And it's true - those files really don't exist starting with google/appengine/ - but I'm unsure how the required_once even makes up those file names

Can I use the local server to update/install plugins or will this screw up some file paths in the Wordpress database?

Set Content-Type when upload a file

I successfully upload a file to my bucket in GCStorage.

The question is that I do not see how can I set the max-age parameter in the metadata using the PHP API.

Here is the code I use:

$file = fopen($_SERVER['DOCUMENT_ROOT']."/uploads/example_50.jpg", 'r');
$bucket = $storage->bucket("my_bucket");
$object = $bucket->upload($file, [
          'name' => "example_50.jpg"
       ]);
$object = $bucket->object("example_50.jpg");
$object->update(['acl' => []], ['predefinedAcl' => 'PUBLICREAD', 'max-age' => 36000]);

As you can see, I have tried it but no success.

Any idea?

App Engine / Wordpress

Upon a successful app build and deployment to App Engine, once I decided to promote the version with Wordpress installed (omitted the --promote --stop-previous-version flags) I am receiving a 403 error at my project url, both the .appspot.com domain and custom domain. I tried multiple urls such as:

  • /wp
  • /wordpress
  • /app/wordpress
  • /wp-login.php
  • /wp-config.php

thinking something functioning may be at one of those options.

I had checked the logs for anything obscene, but could not see anything causing any issues.

I would really appreciate any help to figure my problem out. Let me know if there's any info I can provide that would help.

Consider moving to Silex

The flat-file PHP style samples are good in the fact they are simple, but we may be able to have something even more elegant if we incorporate silex and then have each sample be just a callback function for the sample. Then the samples could all be run at once while still maintaining readability. See the python-docs-samples for reference.

However, it still may be cleaner to keep them as-is, so we'll just have to see as we create new samples what the best method is.

memcache php instrucitons should read memcached

please replace /memcache/ with /memcached/ in README.md

Store and retrieve values from the cache.
``
$ curl http://{YOUR_PROJECT_ID}.appspot.com/memcached/a
$ curl http://{YOUR_PROJECT_ID}.appspot.com/memcached/a -T hello.txt
$ curl http://{YOUR_PROJECT_ID}.appspot.com/memcached/a

Wordpress "document_root" issue

The generated app.yaml looks like this:

runtime: custom
vm: true

beta_settings:
cloud_sql_instances: PROJECT_NAME:us-central1:wp

runtime_config:
document_root: wordpress

Error

Beginning deployment...
ERROR: (gcloud.preview.app.deploy) Unknown runtime_config entry : document_root.

Error Reporting sample is not working.

I realized today that the following Error Reporting sample:

$msg = array(
        'message' => $e->getMessage(),
        'serviceContext' => array('service' => 'myapp'),
        // ... add more metadata
    );

Does not produce log messages that are processed by Stackdriver Error Reporting.

While waiting for the Stackdriver error parser to be updated, we must update our code sample to log errors in the appropriate format:

This code produces a payload that is correctly processed, I tested it and another person confirmed:

$msg = array(
        'message' => sprintf("PHP Notice: %s", (string)$e),
        'serviceContext' => array('service' => 'myapp'),
        // ... add more metadata
    );

I wanted to submit a PR, but realize that there are tests associated. Please update the sample as soon as possible to fix the Stackdriver Error Reporting compute engine instructions: https://cloud.google.com/error-reporting/docs/setup/compute-engine

An error with php wordpress-helper.php setup (Flexible Environment)

When I got the instance prompted I have the following error.

Please select the region of your Cloud SQL instance (defaults to us-central1)
  [0] us-central1
  [1] us-east1
  [2] europe-west1
  [3] asia-east1
 > 3
Using a db_region: asia-east1
Downloading the WordPress archive...

Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in /Users/xxx/php-docs-samples/appengine/wordpress/src/Project.php on line 47

Warning: file_get_contents(): Failed to enable crypto in /Users/xxx/php-docs-samples/appengine/wordpress/src/Project.php on line 47

Warning: file_get_contents(https://wordpress.org/latest.tar.gz): failed to open stream: operation failed in /Users/xxx/php-docs-samples/appengine/wordpress/src/Project.php on line 47

                                                                               
  **[UnexpectedValueException]                                                   
  internal corruption of phar "/private/var/folders/r_/_b85hgnd7lx155j35n8hbd  
  mm0000gn/T/latest.tar.gz" (truncated entry)**         

I have OpenSSL 1.0.2j and installed it by MacPorts.
I have PHP 5.6.24.

Your help would be appreciated.

I'am new here and please help me to apply WordPress.

@tmatsuo @jmdobry
The media file was saved localhost:8080/_ah/gcs/app_default_bucket/filename
It worked during the development time.
But when I continuously developed next day, the file in the Media library has been missing.

I followed the google documentation to solve the above issue.

So, I have installed the client library using $ composer require google/cloud /PATH/TO/MY_PROJECT/ directory where app.yaml is being.
And, I have this script linked from Google. (php-docs-samples/storage/quickstart/quickstart.php)

I don't know how to run this client libarary with my WordPress project.

The help would be appreciated.

[App Engine] Wordpress Standard Environment - Functionality to use CloudSQL 2nd gen

When running the WordPress code generation, It does not let you populate the CloudSQL connection name with the region. I have created a fork with a rough implantation of this feature.

Would there be an interest to add the functionality to choose between using 1st or 2nd generation CloudSQL instance?

Current example behavior:

:/cloudsql/{{project_id}}:{{db_instance}}

Expected example behavior:

:/cloudsql/{{project_id}}:{{db_region}}:{{db_instance}}

Issue with DeployTest

When running phpunit:

PHP Strict Standards:  Non-static method Google\Cloud\Test\DeployTest::downloadPhpmyadmin() 
should not be called statically in 
php-docs-samples/appengine/standard/phpmyadmin/tests/DeployTest.php on line 114

Strict Standards: Non-static method Google\Cloud\Test\DeployTest::downloadPhpmyadmin() 
should not be called statically in 
php-docs-samples/appengine/standard/phpmyadmin/tests/DeployTest.php on line 114

Use `runtime: php` if possible

Some directories still have runtime: custom, but we should use runtime: php if possible.

  • appengine/flexible/symfony
  • appengine/flexible/drupal8

Question on Instances

@tmatsuo

If I have one instance created and want to create multiple wordpress sites, do I have to create each instance for each project?

Can I run more than one database on a single instance?

What is the benefit and disadvantage of either?

How to test WordPress Flexible env. locally

hello everyone!

I would like to test a WordPress application (Flexible Environment) locally with local database, not Cloud SQL.

I have scripted
$ php -S localhost:8080 wordpress
It didn't work and got the following errors:
`Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0

Fatal error: Unknown: Failed opening required 'wordpress' (include_path='.:') in Unknown on line 0`

I think the problem is in my app.yaml.

# application: xxxx
# version: 2017-01-10-test
service: default
runtime: php
env: flex

beta_settings:
  cloud_sql_instances: "xxxx:asia-northeast1:xxxxx"

runtime_config:
  document_root: wordpress

env_variables:
  WHITELIST_FUNCTIONS: escapeshellarg,escapeshellcmd,exec,pclose,popen,shell_exec,phpversion,php_uname

Please help!

Installing and missing files

Hi,

I'm following the tutorial about how to install the API and once cloned the repository, I try to get access cd php-docs-samples/storage/cli and not found.

Even if you try the 4th step for installing dependences, composer.phar is not found in any directory.

What's missing in my procedure?

Cannot access mysql 2nd gen through proxy

Strangely, there was one time that I followed your Wordpress instructions and everything worked fine. That was with my old GCP account.

My client created their own account and I've tried to duplicate the process, but can't login to MySQL through the proxy. (See errors below.)

Started up the proxy.

Dougs-Mac:secondmarketcapital-website doug$ ../cloud_sql_proxy -dir /tmp/cloudsql -instances=secondmarketcapital-website:us-central1:wp=tcp:3306 -credential_file=secondmarketcapital-website-169172622c01.json &
[1] 27461
Dougs-Mac:secondmarketcapital-website doug$ 2016/08/14 22:36:18 Listening on 127.0.0.1:3306 for secondmarketcapital-website:us-central1:wp
2016/08/14 22:36:18 Ready for new connections

Tried to connect.

Dougs-Mac:secondmarketcapital-website doug$ /usr/local/mysql/bin/mysql -h 127.0.0.1 -u root -p
Enter password:
2016/08/14 22:59:19 New connection for "secondmarketcapital-website:us-central1:wp"
2016/08/14 22:59:19 couldn't connect to "secondmarketcapital-website:us-central1:wp": ensure that the account has access to "secondmarketcapital-website:us-central1:wp" (and make sure there's no typo in that name). Error during createEphemeral for secondmarketcapital-website:us-central1:wp: googleapi: Error 403: The client is not authorized to make this request., notAuthorized
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0

Something makes me think I've not don't the service account correctly. Under "select a role" I picked "Project/Service Account Actor", but I'm not sure that was correct.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.