Whitelisted for PHP in GAE - php

I'm completely new to GAE. I'm aiming to build a webapp on Google Cloud SQL and GAE, using PHP to write to/from the database. I've got it working locally through the GoogleAppEngineLauncher localhost server, both succeeding at HelloWorld and reading from the Google Cloud SQL through PHP. When I upload to GAE, not even the HelloWorld will work.
One guess would be that PHP is not enabled on my GAE. I clicked the opt-in, and it said I've been whitelisted, but how can I verify it is turned on?
Cheers,
Ben

There is no whitelisting anymore, anybody can use the runtime.
Suggest you go to the admin console and look at the logs for your application to try and debug what might be going wrong.

Related

connect webpack devserver (HMR) with PHP project running with virtual host

Currently, I developing a WordPress plugin with React frontend.
I tried to connect my backend (PHP) running on a virtual host with webpack devserver with hot module replacement (HMR).
Is there any config how to do it.
note: I tried with devserver proxy but cant figure it out.
Thanks in advance.
Getting HMR is always complicated for custom setup like these. Theoretically, this is pretty simple. You simply need to run the webpack-dev-server with the HMR module. On your PHP file, make sure it uses the JS file generated from webpack-dev-server. The code to refresh is bundled in the JS file so it should work.
However, the devil is in the details. You'll need to make sure the communication between your page and webpack-dev-server works without issue. Monitor your websocket network request and make sure they communicate as expected.
An issue you'll probably encounter is security since the websocket connection is expecting a different host. In this case, you can use config from the following answer: I am getting an "Invalid Host header" message when connecting to webpack-dev-server remotely
Another issue could be that the JS file tries to connect to the wrong location. Eg: It thinks that your host is where the websocket connection is. If this is the case, you can use the public setting. See here for documentation: https://webpack.js.org/configuration/dev-server/#devserverpublic
To me this is akin to running with a reverse proxy. You can see this discussion to understand the problem: https://github.com/webpack/webpack-dev-server/issues/804
There might be other problems. You just need to check the websocket connection and make sure they communicate without problems
How you refer to the generated js file is a separate problem. A simple example would be setting the port to 8081 and bundling the js file into bundle.js. Then in your php code, refer to it as http://localhost:8081/bundle.js

PHP application using Windows Authentication to a MSSQL server

This is not a new topic, but the information I find is always covering only a bit or not exactly what I would need. Here's the "issue"
I'm building a web application, on a Debian / Apache / PHP host.
The web server is NOT in our Active Directory, nor will it be.
Now the web application would need to query Microsoft SQL servers to gather the information to display and so on.
Now, I've installed the Microsoft SQL drivers (version 17) and try to connect. This gives errors because we only allow windows authentication and not directly SQL authentication.
This is where the problem starts. I cannot find any proper documentation on how to get this working. It seems that if you connect without UID and PWD, it tries to logon with the UID owner of the process. This is in this case the APACHE user...which is an account on the Linux server, not known in the Active Directory /Domain. I can't have the Apache server run as a windows account, since that will impact other domains and applications running on that web server. Meaning I'm stuck....
So the questions are basically:
Is there really no proper solution to implement Windows Authentication to MSSQL with PHP (so without work arounds and so on?
Is there any site where this is explained in detail or any developed module for PHP, maybe with javascript or anything.
I can't believe this is not possible, but can't find any working solutions...
Thanks in advance everyone for taking the time to read and reply!

Azure App Service "Has Encountered an Error String Match Failed. String Not Found"

We're hosting a php website on Azure App Service.
Sometimes it is down and displays this error:
"Has Encountered an Error String Match Failed. String Not Found"
After restarting the App Service it works again. I'm quite sure it has nothing to do with the PHP part of it. Unfortunately I wasn't able to find anything helpful.
Why does it happen and how can we fix it?
Here is what MS Support wrote
The application site content is hosted within Web App Azure App Services are backed by Azure Storage in a durable manner. The application accesses the site contents as file shares to allow for application compatibility and availability. Unfortunately, there have been a few cases in which sites are unable to access their content, due to storage being unavailable via our file servers. The causes for this may include transient storage/network availability blips, file server maintenance (rebooting/OS patching) or even crashes.
Possible "fixes":
Use the Local cache feature.
Upgrade the service plan to premium V2, it is using SSD storage, and have faster speed to read and write.
Using VM to host website.
Ensure Always-on feature is ON and that PHP version is correctly set on the Portal.
Try enabling logging. To do this:
Use Kudu Console and go into D:\home\site\wwwroot
In your .user.ini file, add the following line (you can type touch .user.ini to create the file if it doesn't exist, and don't forget the starting dot on the .user.ini file!):
log_errors = On
Restart your site
Make a few failing requests to get some logging going.
Now, from Kudu Console, go to D:\home\LogFiles and open up (or download) php_errors.log.
At the end, you'll find the most recent entries, which may give clues as to what's going on.
Reference:https://github.com/projectkudu/kudu/wiki/Troubleshooting-PHP-errors

Using my php scripts in Android to access database

I need some major help in setting up my android app to add/receive data to/from my database. I'm using Amazon's RDS service in connection with xampp's phpMyAdmin. I've already successfully connected my DB instance to the database in phpMyAdmin. Also, I've written my php scripts to do basic CRUD (Create, Read, Update, Delete) commands in SQL. I've been following this tutorial.
The problem for me is, in his tutorial he is using strings like this:
private static String url_all_products = "http://api.androidhive.info/android_connect/get_all_products.php";
to run his php scripts in a call to makeHttpRequest(url_all_products). But I don't have my own website to do this and I'm pretty sure I don't need one to do this.
Next, I have a test.php file that does a simple echo statement and it works when I run this in a web browser:
http://localhost/phpfiles/test.php
Which leads me to my second problem. I don't want to use localhost because I need these php files and the ability to retrieve data from the database to be accessible to anyone using my app. This is the sole reason I'm using Amazon's RDS service so my database can be accessed on the cloud.
So how can I use the host address provided to me by Amazon RDS to access the database and where do I store all the php files so I can properly use them in Android the way the tutorial shows? They are currently saved in xampp/htdocs/phpfiles/.
I feel like I'm missing some fundamental understanding of all this and I'm going about it all wrong. If someone can point me in the right direction that would make my day.
It sounds like you don't really need the XAMPP install on your local machine at all. You're hosting this on Amazon and you want it to be available to the internet, so your local computer isn't involved. You can use XAMPP locally for testing and development, but for production use you'll be exclusively on the Amazon RDS cloud.
But I don't have my own website to do this and I'm pretty sure I don't need one to do this.
You may not want a website, but you do want your services hosted on the internet. That's what your RDS instance is for, and technically the tutorial is referring to an API which happens to be exposed through a web page. This is a much better idea than opening MySQL directly to the internet on port 3306.
You'll then use your Amazon host — for which you really should use a FQDN such as api.example.com rather than the IP address, but the IP address will work just fine from a technical aspect.
The files you refer to are on your local XAMPP installation; in the xampp/htdocs/phpfiles/ folder, and need to instead be on the RDS instance.
Then your application accesses the API you expose in those files which return information back to your application.

Android-PHP-mysql other device can't write data

I have create an android app which use register and login at my website using PHP and mysql.
I have test it couple of time on my device and on emulator and it work just fine.
And then I ask my friend to try it on his device, but when he try to register(which is write data to mysql via php and json from his device, from his internet connection) it failed. The application hang for a while and then show warning app stop... or something like that...
What make this happen?
is it from php side which cause this? the file permission?
from mysql side?
or something else?
Is the webserver at your location? Maybe it's a setting in the way you configured your settings. Make sure that your ports are forwarded correctly
Please provide more information, improve your question, for example:
Is your friend able to connect to the php website via a browser?
Have you checked the log files of your web-server (is your friend actually connecting to your web server?)
You might try to debug data-traffic and check 'what' is going on by using a debugging proxy-tool, for example:
http://www.fiddler2.com/fiddler2/

Categories