Casperjs - php in heroku app
AndreaGelmini opened this issue · 9 comments
Hello.
I'm trying to install the script in a Heroku app just that I'm having a few problem. You would you be able to help out ??
Hello, can you paste the error messages or the logs?
Unfortunately I have never worked with Heroku
First.. the error
Creation the app...
xxx@xxx-laptop:~/Scrivania/Progetti/QuoteServlet$ git clone https://github.com/alwex/php-casperjs.git Cloning into 'php-casperjs'... remote: Counting objects: 366, done. remote: Total 366 (delta 0), reused 0 (delta 0), pack-reused 365 Ricezione degli oggetti: 100% (366/366), 60.76 KiB | 0 bytes/s, done. Risoluzione dei delta: 100% (144/144), done. Checking connectivity... fatto. xxx@xxx-laptop:~/Scrivania/Progetti/QuoteServlet$ cd php-casperjs xxx@xxx-laptop:~/Scrivania/Progetti/QuoteServlet/php-casperjs$ heroku create --stack cedar --buildpack https://github.com/ddollar/heroku-buildpack-multi.git
`xxx@xxx-xxx:~/Scrivania/Progetti/QuoteServlet/php-casperjs$ git push heroku master
Counting objects: 361, done.
Compressing objects: 100% (118/118), done.
Writing objects: 100% (361/361), 60.01 KiB | 0 bytes/s, done.
Total 361 (delta 144), reused 361 (delta 144)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Failed to detect set buildpack https://github.com/ddollar/heroku-buildpack-multi.git
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to desolate-lowlands-88532.
remote:
To https://git.heroku.com/desolate-lowlands-88532.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/desolate-lowlands-88532.git'
Excuse me, but also I do not know what to do with heroku
`
I think you should use composer for all your php dependencies so that heroku will automatically detect your application type thanks to composer.json. Another solution would be to force the buildpack to heroku/php
, as I have never used heroku, I am not sure.
Hello and thanks for the big hand that you're giving me ..
I have Scopeto that devevo insert a index.php file in the root of the project and called Procfile file to run the server apace.
For not knowing neither read nor write (it is a manner of speaking Italian) I also installed the built pack node and to casper.
Only now I can not understand one thing .. when I go to paste your sample code in my index.php me back this error ..
Fatal error: Uncaught Error: Class 'Browser\Casper' not found in /app/index.php:9 Stack trace: #0 {main} thrown in /app/index.php on line 9
Hello, if you are not using composer and its autoloader, you should require the file by yourself with a require_once('path/to/lib/src/Browser/Casper.php')
to make it available in your index.php
file.
Thanks again .. now seems to turn everything ..
PS: composer use but I can not use automatic ... I do not know why but puttingrequire_once ( 'app / src / Browser / Casper.php')
goes but it creates an error that I resolved I add it include(.: / app /. heroku / php / lib / php);
auks, or something like that .. but now gives me a white pages ...: -C
I should banging your head still for a while ... To make you understand why I would have to access a site fill out a form and retrieve the content of some css elements of a page in json format or html this process repeated for about 30 sites ..
They have commissioned a price comparison but prices have generated demand for request
AZZ.
Hello..
So I have not found a solution. I explain what I did / I'm doing ..
I have re-done the entire installation again.
As you recommended I "installed" through npm is Phantomjs that CasperJs.
I recreated the vendor folder with $ composer update
I plugged in index.php require ('vendor / autoload.php');
at the end of these operations
I pointed to the app I get this error:
Fatal error: not detected Exception: Can not find CasperJS. in /app/src/Browser/Casper.php:591 Stack trace: # 0 /app/index.php(33): Browser \ Casper-> run () # 1 {main} thrown in / app / src / Browser / Casper.php on line 591
Hi,
if you are using composer and npm, just add the following post update command to your composer.json
"scripts": {
"post-update-cmd": [
"npm install",
"ln -sf ../node_modules/casperjs/bin/casperjs ./bin/casperjs"
]
}
Then composer update
and in your php code
$casper = new Browser('./bin/casperjs');
npm install
create a node_modules
in the directory you are executing the command line with the required packages. You just need to make casperjs
binary available to your code and it should work.
Hello
Therefore. I did as you suggested but the result does not change.
this is the my index.php file
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require('vendor/autoload.php');
use Browser\Casper;
$casper = new Browser('./bin/casperjs');
// forward options to phantomJS
// for example to ignore ssl errors
$casper->setOptions(array(
'ignore-ssl-errors' => 'yes'
));`
// navigate to google web page
$casper->start('http://www.google.com');
// fill the search form and submit it with input's name
$casper->fillForm(
'form[action="/search"]',
array(
'q' => 'studio aef'
),
true);
// wait for 5 seconds (have a coffee)
$casper->wait(5000);
// run the casper script
$casper->run();
// check the urls casper get through
var_dump($casper->getRequestedUrls());
// need to debug? just check the casper output
echo "Output
";
var_dump($casper->getOutput());
echo "
";
// need to debug? just check the casper output
echo "OutputHTML
";
var_dump($casper->getHTML());
echo "
";
// need to debug? just check the casper output
echo "getCurrentPageContent
";
var_dump($casper->getCurrentPageContent());
echo "
";
But when I run the app comes out this error.
Fatal error: Uncaught Error: Class 'Browser' not found in /app/index.php:10 Stack trace: #0 {main} thrown in /app/index.php on line 10