| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Debugging</title>
-
- <meta name="author" content="Jonny W">
- <!-- Enable responsive viewport -->
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
- <!--[if lt IE 9]>
- <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
- <![endif]-->
- <!-- Le styles -->
- <link href="http://jonnnnyw.github.io/php-phantomjs/assets/resources/bootstrap/css/bootstrap.min.css" rel="stylesheet">
- <link href="http://jonnnnyw.github.io/php-phantomjs/assets/resources/font-awesome/css/font-awesome.min.css" rel="stylesheet">
- <link href="http://jonnnnyw.github.io/php-phantomjs/assets/resources/syntax/syntax.css" rel="stylesheet">
- <link href="http://jonnnnyw.github.io/php-phantomjs/assets/css/style.css" rel="stylesheet">
- <!-- Le fav and touch icons -->
- <!-- Update these with your own images
- <link rel="shortcut icon" href="images/favicon.ico">
- <link rel="apple-touch-icon" href="images/apple-touch-icon.png">
- <link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png">
- <link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png">
- -->
- <link rel="alternate" type="application/rss+xml" title="" href="http://jonnnnyw.github.io/php-phantomjs/feed.xml">
- <script>
- (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
- (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
- m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
- })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
-
- ga('create', 'UA-53289013-1', 'auto');
- ga('send', 'pageview');
- </script>
- </head>
- <body>
-
-
- <nav class="navbar navbar-default visible-xs" role="navigation" id="global-nav">
- <!-- Brand and toggle get grouped for better mobile display -->
- <div class="navbar-header">
- <button type="button" class="navbar-toggle" data-parent="#global-nav" data-toggle="collapse" data-target="#navbar-collapse-main">
- <span class="sr-only">Toggle navigation</span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- </button>
-
- <button type="button" class="navbar-toggle version-toggle" data-parent="#global-nav" data-toggle="collapse" data-target="#navbar-collapse-version">
- <span class="sr-only">Toggle navigation</span>
- <span class="fa fa-terminal"><b>4.0</b> version</</span>
- </button>
-
- <a class="navbar-brand" href="http://jonnnnyw.github.io/php-phantomjs/">
- <img src="http://jonnnnyw.github.io/php-phantomjs/assets/media/phantomjs-small.png" class="img-circle" />
- PHP PhantomJs
- </a>
- </div>
-
- <div class="panel">
- <!-- Collect the nav links, forms, and other content for toggling -->
- <div class="collapse navbar-collapse" id="navbar-collapse-version">
- <ul class="nav navbar-nav">
- <li><a href="http://jonnnnyw.github.io/php-phantomjs/4.0/" title="Version 4.0" class="active"><b>4.0</b> version</a></li>
- <li><a href="http://jonnnnyw.github.io/php-phantomjs/3.0/" title="Version 3.0"><b>3.0</b> version</a></li>
- </ul>
- </div><!-- /.navbar-collapse -->
- </div>
-
- <div class="panel">
- <!-- Collect the nav links, forms, and other content for toggling -->
- <div class="collapse navbar-collapse" id="navbar-collapse-main">
- <ul class="nav navbar-nav">
-
- <li><a href="http://jonnnnyw.github.io/php-phantomjs/4.0/">Introduction</a></li>
-
- <li><a href="http://jonnnnyw.github.io/php-phantomjs/4.0/2-installation/">Installation</a></li>
-
- <li><a href="http://jonnnnyw.github.io/php-phantomjs/4.0/3-usage/">Usage</a></li>
-
- <li><a href="http://jonnnnyw.github.io/php-phantomjs/4.0/4-custom-scripts/">Custom Scripts</a></li>
-
- <li><a href="http://jonnnnyw.github.io/php-phantomjs/4.0/5-caching/">Caching</a></li>
-
- <li><a href="http://jonnnnyw.github.io/php-phantomjs/4.0/6-debugging/">Debugging</a></li>
-
- <li><a href="http://jonnnnyw.github.io/php-phantomjs/4.0/7-troubleshooting/">Troubleshooting</a></li>
-
- </ul>
- </div><!-- /.navbar-collapse -->
- </div>
-
- </nav>
-
- <!-- version-menu-dropdown -->
- <div class="btn-group hidden-xs" id="nav-version">
- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
- <i class="fa fa-terminal"><b>4.0</b> version</i>
- </button>
- <ul class="dropdown-menu" role="menu">
- <li><a href="http://jonnnnyw.github.io/php-phantomjs/4.0/" title="4.0 version" class="active"><b>4.0</b> version</a></li>
- <li><a href="http://jonnnnyw.github.io/php-phantomjs/3.0/" title="3.0 version"><b>3.0</b> version</a></li>
- <li class="divider"></li>
- </ul>
- </div>
-
- <!-- nav-menu-dropdown -->
- <div class="btn-group hidden-xs" id="nav-menu">
- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
- <i class="fa fa-bars"></i>
- </button>
- <ul class="dropdown-menu" role="menu">
-
- <li><a href="http://jonnnnyw.github.io/php-phantomjs/4.0/"><i class="fa fa-folder"></i>Introduction</a></li>
-
- <li><a href="http://jonnnnyw.github.io/php-phantomjs/4.0/2-installation/"><i class="fa fa-folder"></i>Installation</a></li>
-
- <li><a href="http://jonnnnyw.github.io/php-phantomjs/4.0/3-usage/"><i class="fa fa-folder"></i>Usage</a></li>
-
- <li><a href="http://jonnnnyw.github.io/php-phantomjs/4.0/4-custom-scripts/"><i class="fa fa-folder"></i>Custom Scripts</a></li>
-
- <li><a href="http://jonnnnyw.github.io/php-phantomjs/4.0/5-caching/"><i class="fa fa-folder"></i>Caching</a></li>
-
- <li><a href="http://jonnnnyw.github.io/php-phantomjs/4.0/6-debugging/"><i class="fa fa-folder"></i>Debugging</a></li>
-
- <li><a href="http://jonnnnyw.github.io/php-phantomjs/4.0/7-troubleshooting/"><i class="fa fa-folder"></i>Troubleshooting</a></li>
-
- <li class="divider"></li>
- <li><a href="#"><i class="fa fa-arrow-up"></i>Top of Page</a></li>
- </ul>
- </div>
- <div class="col-sm-3 sidebar hidden-xs">
- <! -- sidebar.html -->
- <header class="sidebar-header" role="banner">
- <a href="http://jonnnnyw.github.io/php-phantomjs/">
- <img src="http://jonnnnyw.github.io/php-phantomjs/assets/media/phantomjs.png" class="img-circle" />
- </a>
- <h3 class="title">
- <a href="http://jonnnnyw.github.io/php-phantomjs/">PHP PhantomJs</a>
- </h3>
- </header>
- <div id="bio" class="text-center">
- Run PhantomJS scripts through PHP
- </div>
- <div id="contact-list" class="text-center">
- <ul class="list-unstyled list-inline">
-
- <li>
- <iframe src="http://ghbtns.com/github-btn.html?user=jonnnnyw&repo=php-phantomjs&type=watch&count=true"
- allowtransparency="true" frameborder="0" scrolling="0" width="85" height="20"></iframe>
- </li>
-
-
- <li>
- <iframe src="http://ghbtns.com/github-btn.html?user=jonnnnyw&repo=php-phantomjs&type=fork&count=true"
- allowtransparency="true" frameborder="0" scrolling="0" width="83" height="20"></iframe>
- </li>
-
- </ul>
- </div>
- <! -- sidebar.html end -->
- </div>
- <p id="version-notice">You are currently viewing version <span>4.0</span> documentation.</p>
- <div class="col-sm-9 col-sm-offset-3">
- <div class="page-header">
- <h1>Debugging </h1>
- </div>
-
- <article>
-
- <div class="col-sm-10">
-
- <div class="article_body">
- <ul>
- <li><a href="#phantomjs-log">PhantomJS log</a></li>
- <li><a href="#javascript-console-log">Javascript console log</a></li>
- <li><a href="#validation-errors">Validation errors</a></li>
- </ul>
- <hr />
- <h2 id="phantomjs-log">PhantomJS log</h2>
- <p>Verbose logging can be enabled for PhantomJS by setting the debug flag on the client. This is the same as setting the PhantomJS <code>--debug=true</code> command line option.</p>
- <figure class="highlight"><pre><code class="language-php" data-lang="php"><span class="x"> </span>
- <span class="x"> </span><span class="cp"><?php</span>
-
- <span class="k">use</span> <span class="nx">JonnyW\PhantomJs\Client</span><span class="p">;</span>
- <span class="nv">$client</span> <span class="o">=</span> <span class="nx">Client</span><span class="o">::</span><span class="na">getInstance</span><span class="p">();</span>
- <span class="nv">$client</span><span class="o">-></span><span class="na">getEngine</span><span class="p">()</span><span class="o">-></span><span class="na">debug</span><span class="p">(</span><span class="k">true</span><span class="p">);</span></code></pre></figure>
- <p>The client log can be inspected after making a request.</p>
- <figure class="highlight"><pre><code class="language-php" data-lang="php"><span class="x"> </span>
- <span class="x"> </span><span class="cp"><?php</span>
-
- <span class="o">...</span>
-
- <span class="nv">$client</span><span class="o">-></span><span class="na">getLog</span><span class="p">();</span> <span class="c1">// String</span>
-
- <span class="o">...</span></code></pre></figure>
- <blockquote>
- <h4 id="note">Note</h4>
- <p>The client log contains some helpful information specific to the PhantomJS library. In some cases these are present in the log even if debugging is disabled.</p>
- </blockquote>
- <h2 id="javascript-console-log">Javascript console log</h2>
- <p>The response object also provides access to a console log. Any javascript errors raised on the requested page will be present in the response console log.</p>
- <figure class="highlight"><pre><code class="language-php" data-lang="php"><span class="x"> </span>
- <span class="x"> </span><span class="cp"><?php</span>
-
- <span class="o">...</span>
-
- <span class="nv">$response</span><span class="o">-></span><span class="na">getConsole</span><span class="p">();</span> <span class="c1">// Array</span>
-
- <span class="o">...</span></code></pre></figure>
- <h2 id="validation-errors">Validation errors</h2>
- <p>Before a script template is compiled and cached it is validated using the <a href="http://">Esprima</a> javascript validation engine. If the script fails to validate then a <code>JonnyW\PhantomJs\Exception\SyntaxException</code> will be raised. Debug information about any validation errors can be found by calling a <code>getErrors()</code> helper method on the exception instance. This will return an array of error information. </p>
- <figure class="highlight"><pre><code class="language-php" data-lang="php"><span class="x"> </span><span class="cp"><?php</span>
-
- <span class="c1">// $exception->getErrors(); </span>
- <span class="k">array</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span> <span class="p">{</span>
- <span class="k">array</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span> <span class="p">{</span>
- <span class="s1">'lineNumber'</span> <span class="o">=></span> <span class="mi">1</span><span class="p">,</span>
- <span class="s1">'column'</span> <span class="o">=></span> <span class="mi">17</span><span class="p">,</span>
- <span class="s1">'index'</span> <span class="o">=></span> <span class="mi">16</span><span class="p">,</span>
- <span class="s1">'description'</span> <span class="o">=></span> <span class="s1">'Unexpected token ;'</span><span class="p">,</span>
- <span class="s1">'message'</span> <span class="o">=></span> <span class="s1">'Line 1: Unexpected token ;'</span>
- <span class="p">}</span>
- <span class="p">}</span></code></pre></figure>
- <blockquote>
- <h4 id="important">Important</h4>
- <p>Due to a limitation in the validation logic, scripts are currently minified to a single line before validating. This makes the <code>lineNumber</code> value contained in the error output redundant. This is due to be fixed in a future release.</p>
- </blockquote>
- </div>
- </div>
- <div class="clearfix"></div>
-
- <hr>
- <ul class="pager">
-
- <li class="previous"><a href="http://jonnnnyw.github.io/php-phantomjs/4.0/7-troubleshooting/" title="Troubleshooting">← Troubleshooting</a></li>
-
-
- <li class="next"><a href="http://jonnnnyw.github.io/php-phantomjs/4.0/5-caching/" title="Caching">Caching →</a></li>
-
- </ul>
-
-
- </article>
- <footer>
- <hr/>
- <p>
- © 2016 PHP PhantomJs
- </p>
- </footer>
- </div>
- <script type="text/javascript" src="http://jonnnnyw.github.io/php-phantomjs/assets/resources/jquery/jquery.min.js"></script>
- <script type="text/javascript" src="http://jonnnnyw.github.io/php-phantomjs/assets/resources/bootstrap/js/bootstrap.min.js"></script>
- <script type="text/javascript" src="http://jonnnnyw.github.io/php-phantomjs/assets/js/app.js"></script>
-
- </body>
- </html>
|