PHP chrome-php / headless-chromium-php - php

Hello I am using the chrome-php & headless-chromium packages for PHP and installed the package, on the web server I get this error:
Exception: RuntimeException: Cannot read chrome version, make sure you provided the correct chrome executable using: "chrome". Additional info: sh: 1: exec: chrome: not found
I am using a Mac and have this in my ~/.zshrc file:
alias chrome="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
export chrome=/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
and ~/.bash_profile file:
alias chrome="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
In some of the solutions online relating to this issue its asking me to make Chrome executable which I have

Your web server isn't going to have access to the alias that you defined in your user's home directory.
According to https://github.com/chrome-php/headless-chromium-php, you probably want to set the environmental variable CHROME_PATH in your web server to point to your Chrome executable binary.

Related

Selenium: FirefoxProfile exception Can't load the profile. Python script called from PHP

My python script has the following code:
firefox_profile = webdriver.FirefoxProfile()
self.driver = webdriver.Firefox(firefox_profile=firefox_profile)
When I execute the script from bash it works, but if I call the script from a PHP file, with the following command:
shell_exec("python path_to_the_script");
I receive the exception:
selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: /tmp/tmp7Ob0z6/webdriver-py-profilecopy If you specified a log_file in the FirefoxBinary constructor, check it for details.
I've also tried to set the profile manually, like this:
firefox_profile = webdriver.FirefoxProfile(profile_directory='path_to_the_profile_dir')
But nothing changed, while if I set the profile directory path like this:
firefox_profile = webdriver.FirefoxProfile(profile_directory='path_to_the_profile_dir')
firefox_profile.profile_dir = 'path_to_the_profile_dir'
The exception error changes to this:
selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: path_to_the_profile_dir If you specified a log_file in the FirefoxBinary constructor, check it for details.
I've set the permissions to 777 for all the involved directories, and also tried to override the FirefoxBinary.launch_browser function so that it uses a greater timeout value, but id did not work.
I'm using Python 2.7, Selenium 2.53.6 and Firefox 46.0.1
Firefox is working in headless mode, through Xvfb and pyvirtualdisplay.
This happens because you have updated firefox to a version that's no longer supported by selenium.
So to fix this you have 2 options.
Downgrade your firefox to an older version then 47
Update Selenium and Install geckodriver (recommended and easy)
If you have ubuntu follow this fix below:
1. Update selenium with "sudo pip install -U selenium"
2. Download the geckodriver from github -->
Gecko Github Link
3. Extract the tar.gz folder and move the gecko executable to /usr/local/bin
4. Now open your terminal and enter this command: export PATH=$PATH:/usr/local/bin/geckodriver
That should fix the issue... atleast it worked for me.
My Source: StackOverflow - Geckodriver
If that didn't fix your issue check your firefox profile name
like this
fp = webdriver.FirefoxProfile('/home/YOUR_USERNAME/.mozilla/firefox/YOUR_PROFILE_NAME.default')
driver = webdriver.Firefox(firefox_profile=fp)
To find your firefox profile name open your file browser and enable "show hidden files" go to "Home/.mozilla/firefox" and you'll see your firefox profile folder.
I hope that solved your issue

unable to use dev_appserver.py to run the local development server on mac

I was following the tutorial on Google cloud platform to run the local server for the hello-world app, and using the dev_appserver.py command, however, the terminal complain with the message as below:
$ dev_appserver.py .
INFO 2016-10-22 21:59:53,084 devappserver2.py:769] Skipping SDK update check.
INFO 2016-10-22 21:59:53,129 api_server.py:205] Starting API server at: http://localhost:56857
INFO 2016-10-22 21:59:53,133 dispatcher.py:197] Starting module "default" running at: http://localhost:8080
INFO 2016-10-22 21:59:53,137 admin_server.py:116] Starting admin server at: http://localhost:8000
ERROR 2016-10-22 21:59:54,141 php_runtime.py:348] The PHP runtime is not available
Traceback (most recent call last):
File "/Users/Dale/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/php_runtime.py", line 344, in new_instance
self._check_binaries(php_executable_path, gae_extension_path)
File "/Users/Dale/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/php_runtime.py", line 265, in _check_binaries
raise _PHPBinaryError('The development server must be started with the '
_PHPBinaryError: The development server must be started with the --php_executable_path flag set to the path of the php-cgi binary.
what does the complain mean? Is there anything wrong with the php_runtime.py? and how can i set it straight? Thank you so much.
If you're on a Mac, you need to run this command:
gcloud components install app-engine-php-darwin
If you're on Linux, you need to provide --php_executable_path as the error message states.

php command is not recognized in wamp

I'm working on websocket. I came across this article, and simply downloaded their file and try running it in my localhost.
https://www.sanwebe.com/2013/05/chat-using-websocket-php-socket
What I understand is, they want to sue local server's websocket server.
But I have problem in starting up the server. I'm using windows 10 with wamp 2.2. As I checked webscket is enabled in my php.ini's extention.
I followed this example to cmd the right path to start it but to no avail:
https://www.sanwebe.com/2013/05/chat-using-websocket-php-socket/comment-page-1#comment-5593
It says 'php.exe' is not recognized as an internal or external ...
I then searched online again, thus set the path to my php folder in the system's environment variable. The path is: C:\wamp\bin\php. Then I closed the cmd and relaunched. Nothing worked out. The same error shows up.
This is what I did on cmd:
1) cd C:\wamp\bin\php
2) php.exe -q C:\projects\myfolder\server.php
Please help me to connect to wamp server's websocket to run the example I've downloaded.In the console, the error shown is:
WebSocket connection to 'ws://localhost:9000/demo/server.php' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
I found the answer from this site: http://rodrixar.blogspot.my/2011/07/how-to-run-php-sockets-in-wamp.html
I did the following,
1) open cmd
2) cd C:\wamp\bin\php\php5.6.19
3)php.exe -q C:\projects\mysite\server.php
4) Firewall open up and allow access for CLI
5) now connection made already..

installing php symfony installer

I am using this cmd
php -r "file_put_contents('symfony', file_get_contents('https://symfony.com/installer'));"
output i am getting
Warning: file_get_contents(https://symfony.com/installer): failed to open stream
: No connection could be made because the target machine actively refused it.
in Command line code on line 1
i on proxy so that above cmd will not work directly .
I found some solution on stack overflow
Install Symfony on Windows behind proxy server with NTLM authentication
but its not working for me
I tried setting http_proxy and https_proxy env variable but it dint worked for me
Are there any chances of problem because of ssl ?
Can you access https://symfony.com/installer in your browser? If you can, it'll download a PHAR file for you. This file is ready to be used. You can put this in your "projects" directory and use it as:
> php symfony.phar new blog
Or you can move it to a location that's in your PATH and create a bat executable file:
#echo off
php "C:\path\to\symfony.phar" %*
Now you can use it like this:
> symfony new blog

phabricator on redhat's openshift

I installed phabricator on openshift using a quickstart from github
https://github.com/CodeBlock/phabricator-openshift-quickstart
I got it running up fine, but I now have two issues:
1.) A setup issue that says apc.stat is enabled and that must be disabled in
/var/lib/openshift/my-user-hash/php/configuration/etc/php.ini
however I cannot access that with sudo command(sudo permission denied), even if I open it normally, I didn't find any apc.stat settings in the php.ini
2.) I can't figure out how set the local path for tracking repositories for diffusion. It says
I must give a path which should be read-writable by phabricator, I tried to give the persistent storage location ..data/ , but it gives me an exception as follows :
Unhandled Exception ("CommandException")
Command failed with error #1!
COMMAND
(cd '../data/' && HOME='/var/lib/openshift/my-user-hash/app-root/runtime/repo/phabricator/support/empty/' git cat-file --batch)
STDOUT
(empty)
STDERR
sh: line 0: cd: ../data/: No such file or directory
how do I fix this?
1) According to Num Duong answer, it seems like u currently could not resolve this issue, probably u should wait for openshift php.ini permissions policy changes.
Anyway this is minor non blocking issue.
2) Modify config file and re-deploy to openshift.
Look for available phabricator options here
U need smth like this: 'repository.default-local-path' => getenv('OPENSHIFT_DATA_DIR'),
P.S. Anyway there is one particular issue with phabricator on openshift that possibly never got resolved: cloning git repositories from OpenShift instances into Phabricator do not
work by SSH, due to permissions regarding the ssh configuration.

Categories