Running Google App Engine PHP on Windows - php

I keep getting Syntax Error: unexpected character after line continuation character when I try to start the localhost server with the following command:
google_appengine\dev_appserver.py --php_executable_path="C:\Computer Science\PHP\php\php-cgi.exe" "C:\Computer Science\PHP\helloworld"
What's wrong?
My app.yaml:
application: helloworld
version: 1
runtime: php
api_version: 1
handlers:
- url: /.*
script: helloworld.php
My helloworld.py
<?php
echo 'Hello, World!';
?>
My directories
/PHP
/php
/php-cgi.exe
/helloworld
/google_appengine
Edit:
I have ran my app using the google app engine launcher, with php sdk and an extra command line flag in the launch settings:
--php_executable_path=C:\Computer Science\PHP\php\php-cgi.exe. The server crashed.

user2481064 use the windows CMD, make sure you're in the same path as your google app engine sdk, i basically put my GAE SDK and application in the same path. Here it is:
Open your windows cmd, make sure you're in the same directory as your sdk.
Type: "google_appengine/dev_appserver.py" --port=9999 --php_executable_path="fullpath\php-cgi.exe" "helloworld/"
If you have another local server like xampp or wamp,make sure you use the --port command to select another listening port as shown above.
4.Press enter and you should have your helloworld script working.
Good luck :)

I too got stuck with this or the other error "SyntaxError: can't assign to operator". Things got better when I stoppped using the Python shell but use the Windows cmd shell.
For my environment, the command I arrive at is
"google_appengine\dev_appserver.py" --php_executable_path="\BitNami\rubystack-1.9.3-10\php\php-cgi.exe" "helloworld/"
(The direction of some of the slashes can be important if you later use parts of the command for separate investigation/diagnose in Windows.) Wow the engine starts despite various errors. At the webbrowser, I was able to see the localhost equivalent of the dashboard at localhost:8000/instances (force-redirected from localhost:8000) BUT the app itself at localhost:8080 (that's 8080) just shows
' "BitNami/rubystack-1.9.3-10/apache2/cgi-bin/php-cgi.exe -v" returned an error [-1072365564] '
Separately running
BitNami\rubystack-1.9.3-10\apache2\cgi-bin\php-cgi.exe -v
reports my version of PHP is 5.4.15. I am not sure if installing a an additional clean PHP will help. Or perhaps I should move on & push the app.

Related

running a php script using ansible throws errors

I am trying to run a php script on a remote server using ansible.
Running the script with the ansible user (which ansible uses to login to the server) works perfectly. The ansible task however fails when there are include statements in my php script.
My php script lays in /srv/project
it tries to include includes/someLibrary.php
Everything works fine when running the script as any user with the correct access rights but when running it via an ansible task
- name: run script
shell: 'php /srv/project/script.php'
it fails with: failed to open stream: No such file or directory in /srv/project/includes/someLibrary.php
Running a very basic php script works nicely though.
I just found the solution to the problem.
The problem was that when I executed the script by hand, I connected to the server and cd'd into the /srv/project directory before calling php script.php PHPs include in this case looks in the current directory for the files I want to include. When ansible connects to the server it did not change the directory thus producing the no such file or directory error. The solution to this is simple as the shell module takes a chdir as an argument to change the directory to the one specified before running the command.
My ansible task now looks as follows:
- name: run script
shell: 'php /srv/project/script.php'
args:
chdir: '/srv/project'
Thanks everyone for your help!
Ansible runs under a non-interactive ssh session, and thus does not apply user environment settings (eg, .bashrc, .bash_profile). This is typically the cause of different behavior when running interactively vs. not. Check the difference between an interactive printenv and raw: printenv via Ansible, and you'll probably find what needs to be set (via an ansible task/play environment: block) to get things working.

OpenTok learning-open-tok issue

I've been following the steps at this link: https://github.com/opentok/learning-opentok-php, and I can't get past the first step because I don't understand what I have to do on this part:
The run-demo file starts the PHP CLI development server (requires PHP >= 5.4) on port 8080. If you want to run your server on another port, edit the file. Finally, start the server using the run-demo script.
And then when i actually run the run-demo script and follow the link: http://localhost:8080/session i get this message on screen "You must run composer install in the sample app directory", and if i try to run the composer it doesent run.

Google App Engine PHP Helloworld Example Does Nothing

I assume I'm making some simple mistake, but I just can't get the Google App Engine PHP SDK (GAE) "helloworld" example to work.
When I attempt to run the example on a Windows XP command line, I get no errors. The dev appserver is ever started on port 8080. I followed the GAE PHP SDK "Getting Started" page to the letter. If I mistype the path name, I get an error on that, but that’s it.
I have installed Python 2.7, PHP 5.4 and the GAE PHP SDK 1.8.3. All seem to work independently without error. Testing such…phpinfo() works, the Python interpreter works as well.
I’ve read all of the other questions/answers on this subject on the Stack(here) but nothing has helped. Here's some details:
My "helloworld" dir (the app.yawl file is there too):
C:\helloworld\helloworld.php
My Google GAE dir:
C:\google_appengine
My PHP dir:
C:\PHP
My Python dir:
C:\Python27
Here's the dev appserver startup command line I'm using in a Windows XP CMD window:
python C:\google_appengine\dev_appserver.py --php_executable_path=C:\PHP\php-cgi.exe C:\helloworld\helloworld
The dev web server does not start, can't see the listener on default port 8080 in netstat.
You said that the app.yawl file is present in the helloworld directory.
Its actually app.yaml . You may have saved that with incorrect extension. Check it.
The other thing I noticed is in the last command you are pointing to the .php file as C:\helloworld\helloworld.
You should actually point to the APPLICATION_DIRECTORY, which in your case is just C:/helloworld/

Google App Engine PHP on windows

I'm trying to get started with using Google app engine with PHP (on Windows 7) and have been trying to follow the helloworld example here.
Problem I am having is in starting the webserver. Whenever I try to run it I get the error
dev_appserver.py: error: too few arguments
I'm typing the following at the command line:
google_appengine\dev_appserver.py --php_executable_path=c:\php\php-cgi c:\appengine\helloworld\
Any suggestions as to what I am doing wrong?
Cheers
Use quotes for arguments.
google_appengine\dev_appserver.py --php_executable_path="c:\php\php-cgi" "c:\appengine\helloworld"
Or use slashes instead of backslashes as directory separator:
google_appengine\dev_appserver.py --php_executable_path=c:/php/php-cgi c:/appengine/helloworld
For best results combine both methods ;)
So I was running into this issue, and tried every permutation of paths using quotes, and switching to the directory where appengine SDK was installed etc. Finally I realized that Python was running the script but it wasn't including the command line arguments being passed in. So I had to manually call python like this:
c:\<python_path>\python <sdk_path>/dev_appserver.py --php_executable_path=c:/php/php-cgi.exe helloworld/
I'm not a python guy so I don't know why the command line arguments got stripped, but I've had this issue with other applications in Windows 7
This answer solved the issue for me.
Just to clarify it a bit, here is how the value under
HKEY_CLASSES_ROOT\Applications\python.exe\shell\open\command
should look in Windows regedit tool.
And it should be the same as the value under this path:
HKEY_CLASSES_ROOT\Python.File\shell\open\command
Solution tested on environment: Python 2.7.5 on Windows 7 (Home Premium) x64.
In fact I had this problem not with PHP App Engine but with Go App Engine. However, it is apparently not App Engine, but rather a Python+Windows issue.
I'm using Windows 7 too.
Here it's my code tested:
dev_appserver.py --php_executable=c:/php/php-cgi.exe c:/appengine/helloworld
Notice! I'm inside google appengine directory.
For example if you installed the SDK in C:
Write first cd google_appengine hit enter, and then use the upper code.
You have to either: give full path to dev_appserver.py
or
cd into the directory where you instaled it
If You followed example to the letter You would have instaled it in C:/{username}/something directory
and the call would be then something/dev_appserver.py as stated in example in helloworld!
Hovever - the example have one error in it: the directory they are proposing is not the same they are using in example call! Thats why make sure the "sometinhg" directory is the same in call as used to instal app engine
after I moved everything to c:\ to simplify the paths I ended up calling it from the dos command prompt like this
C:>\Python27\python C:/google_appengine/dev_appserver.py --php_executable_path=
C:/php/php-cgi.exe c:/google_appengine/helloworld/
And it works!
is the python command line tool the way we should be running this stuff?

Where to start with running a command line in PHP with CPanel hosting

I'm having a look at some PayPal scripts/code examples and a lot of them need a php script running via the command line.
I've never had to run anything from a command line in PHP before so don't know where to start at all. I don't know if I'm using the correct search terms as Google hasn't helped me answer.
Do I need to use a different application or is there something in cPanel I can use?
I get this error:
INSTALLATION ERROR: Please cd to the /home/site_name/public_html/site and run install.php
Use SSH to access the server via the terminal:
http://docs.cpanel.net/twiki/bin/view/11_30/CpanelDocs/ShellAccess
There's instructions on how to connect via PuTTY, then you can go to the directory where the PHP script is run it like:
php myPHPScript.php
If your cPanel has the option to turn on SSH, do it. Then SSH into the server and run the commands -
cd /home/site_name/public_html/site
php install.php

Categories