����JFIF��x�x����'
Server IP : 78.140.185.180 / Your IP : 3.149.250.24 Web Server : LiteSpeed System : Linux cpanel13.v.fozzy.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64 User : builderbox ( 1072) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/builderbox/public_html/vendor/rackspace/php-opencloud/doc/_build/html/ |
Upload File : |
<!DOCTYPE html> <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Debugging — php-opencloud 1.12.1 documentation</title> <link href='https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'> <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> <link rel="top" title="php-opencloud 1.12.1 documentation" href="index.html"/> <link rel="next" title="Caching credentials" href="caching-creds.html"/> <link rel="prev" title="Snapshots" href="services/volume/snapshots.html"/> <script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script> </head> <body class="wy-body-for-nav" role="document"> <div class="wy-grid-for-nav"> <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-nav-search"> <a href="index.html" class="fa fa-home"> php-opencloud</a> <div role="search"> <form id ="rtd-search-form" class="wy-form" action="search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> </div> <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> <ul> <li class="toctree-l1"><a class="reference internal" href="services/autoscale/index.html">Auto Scale v2</a><ul> <li class="toctree-l2"><a class="reference internal" href="services/autoscale/index.html#setup">Setup</a></li> <li class="toctree-l2"><a class="reference internal" href="services/autoscale/index.html#operations">Operations</a></li> <li class="toctree-l2"><a class="reference internal" href="services/autoscale/index.html#glossary">Glossary</a></li> <li class="toctree-l2"><a class="reference internal" href="services/autoscale/index.html#further-links">Further Links</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="services/compute/index.html">Compute v2</a><ul> <li class="toctree-l2"><a class="reference internal" href="services/compute/index.html#setup">Setup</a></li> <li class="toctree-l2"><a class="reference internal" href="services/compute/index.html#operations">Operations</a></li> <li class="toctree-l2"><a class="reference internal" href="services/compute/index.html#glossary">Glossary</a></li> <li class="toctree-l2"><a class="reference internal" href="services/compute/index.html#further-links">Further Links</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="services/database/index.html">Databases v1</a><ul> <li class="toctree-l2"><a class="reference internal" href="services/database/index.html#setup">Setup</a></li> <li class="toctree-l2"><a class="reference internal" href="services/database/index.html#operations">Operations</a></li> <li class="toctree-l2"><a class="reference internal" href="services/database/index.html#glossary">Glossary</a></li> <li class="toctree-l2"><a class="reference internal" href="services/database/index.html#further-links">Further Links</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="services/dns/index.html">DNS v1</a><ul> <li class="toctree-l2"><a class="reference internal" href="services/dns/index.html#setup">Setup</a></li> <li class="toctree-l2"><a class="reference internal" href="services/dns/index.html#operations">Operations</a></li> <li class="toctree-l2"><a class="reference internal" href="services/dns/index.html#glossary">Glossary</a></li> <li class="toctree-l2"><a class="reference internal" href="services/dns/index.html#further-links">Further Links</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="services/identity/index.html">Identity v2</a><ul> <li class="toctree-l2"><a class="reference internal" href="services/identity/index.html#setup">Setup</a></li> <li class="toctree-l2"><a class="reference internal" href="services/identity/index.html#operations">Operations</a></li> <li class="toctree-l2"><a class="reference internal" href="services/identity/index.html#glossary">Glossary</a></li> <li class="toctree-l2"><a class="reference internal" href="services/identity/index.html#further-links">Further Links</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="services/image/index.html">Images v1</a><ul> <li class="toctree-l2"><a class="reference internal" href="services/image/index.html#setup">Setup</a></li> <li class="toctree-l2"><a class="reference internal" href="services/image/index.html#operations">Operations</a></li> <li class="toctree-l2"><a class="reference internal" href="services/image/index.html#glossary">Glossary</a></li> <li class="toctree-l2"><a class="reference internal" href="services/image/index.html#further-links">Further Links</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="services/load-balancer/index.html">Load Balancer v1</a><ul> <li class="toctree-l2"><a class="reference internal" href="services/load-balancer/index.html#setup">Setup</a></li> <li class="toctree-l2"><a class="reference internal" href="services/load-balancer/index.html#operations">Operations</a></li> <li class="toctree-l2"><a class="reference internal" href="services/load-balancer/index.html#glossary">Glossary</a></li> <li class="toctree-l2"><a class="reference internal" href="services/load-balancer/index.html#further-links">Further Links</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="services/monitoring/index.html">Monitoring v1</a><ul> <li class="toctree-l2"><a class="reference internal" href="services/monitoring/index.html#setup">Setup</a></li> <li class="toctree-l2"><a class="reference internal" href="services/monitoring/index.html#operations">Operations</a></li> <li class="toctree-l2"><a class="reference internal" href="services/monitoring/index.html#glossary">Glossary</a></li> <li class="toctree-l2"><a class="reference internal" href="services/monitoring/index.html#further-links">Further links</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="services/networking/index.html">Networking v2</a><ul> <li class="toctree-l2"><a class="reference internal" href="services/networking/index.html#setup">Setup</a></li> <li class="toctree-l2"><a class="reference internal" href="services/networking/index.html#operations">Operations</a></li> <li class="toctree-l2"><a class="reference internal" href="services/networking/index.html#glossary">Glossary</a></li> <li class="toctree-l2"><a class="reference internal" href="services/networking/index.html#further-links">Further links</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="services/object-store/index.html">Object Store v1</a><ul> <li class="toctree-l2"><a class="reference internal" href="services/object-store/index.html#setup">Setup</a></li> <li class="toctree-l2"><a class="reference internal" href="services/object-store/index.html#operations">Operations</a></li> <li class="toctree-l2"><a class="reference internal" href="services/object-store/index.html#glossary">Glossary</a></li> <li class="toctree-l2"><a class="reference internal" href="services/object-store/index.html#further-links">Further links</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="services/orchestration/index.html">Orchestration v1</a><ul> <li class="toctree-l2"><a class="reference internal" href="services/orchestration/index.html#setup">Setup</a></li> <li class="toctree-l2"><a class="reference internal" href="services/orchestration/index.html#operations">Operations</a></li> <li class="toctree-l2"><a class="reference internal" href="services/orchestration/index.html#glossary">Glossary</a></li> <li class="toctree-l2"><a class="reference internal" href="services/orchestration/index.html#further-links">Further links</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="services/queues/index.html">Queues v1</a><ul> <li class="toctree-l2"><a class="reference internal" href="services/queues/index.html#setup">Setup</a></li> <li class="toctree-l2"><a class="reference internal" href="services/queues/index.html#operations">Operations</a></li> <li class="toctree-l2"><a class="reference internal" href="services/queues/index.html#glossary">Glossary</a></li> <li class="toctree-l2"><a class="reference internal" href="services/queues/index.html#further-links">Further links</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="services/volume/index.html">Volumes v1</a><ul> <li class="toctree-l2"><a class="reference internal" href="services/volume/index.html#setup">Setup</a></li> <li class="toctree-l2"><a class="reference internal" href="services/volume/index.html#operations">Operations</a></li> <li class="toctree-l2"><a class="reference internal" href="services/volume/index.html#glossary">Glossary</a></li> <li class="toctree-l2"><a class="reference internal" href="services/volume/index.html#further-links">Further links</a></li> </ul> </li> </ul> <ul class="current"> <li class="toctree-l1 current"><a class="current reference internal" href="">Debugging</a><ul> <li class="toctree-l2"><a class="reference internal" href="#strategy-1-meaningful-exception-handling">Strategy 1: Meaningful exception handling</a></li> <li class="toctree-l2"><a class="reference internal" href="#strategy-2-wire-logging">Strategy 2: Wire logging</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="caching-creds.html">Caching credentials</a><ul> <li class="toctree-l2"><a class="reference internal" href="caching-creds.html#filesystem-example">Filesystem example</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="iterators.html">Iterators</a><ul> <li class="toctree-l2"><a class="reference internal" href="iterators.html#common-behaviour">Common behaviour</a></li> <li class="toctree-l2"><a class="reference internal" href="iterators.html#very-important-note">Very important note</a></li> <li class="toctree-l2"><a class="reference internal" href="iterators.html#using-paginated-collections">Using paginated collections</a></li> <li class="toctree-l2"><a class="reference internal" href="iterators.html#setting-up-a-paginatediterator">Setting up a PaginatedIterator</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="regions.html">Rackspace regions</a></li> <li class="toctree-l1"><a class="reference internal" href="url-types.html">URL types</a><ul> <li class="toctree-l2"><a class="reference internal" href="url-types.html#internalurl">internalURL</a></li> <li class="toctree-l2"><a class="reference internal" href="url-types.html#publicurl">publicURL</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="logging.html">Logging</a><ul> <li class="toctree-l2"><a class="reference internal" href="logging.html#logger-injection">Logger injection</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="http-clients.html">HTTP Clients</a><ul> <li class="toctree-l2"><a class="reference internal" href="http-clients.html#default-http-headers">Default HTTP headers</a></li> <li class="toctree-l2"><a class="reference internal" href="http-clients.html#user-agents">User agents</a></li> <li class="toctree-l2"><a class="reference internal" href="http-clients.html#other-functionality">Other functionality</a></li> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="auth.html">Authentication</a><ul> <li class="toctree-l2"><a class="reference internal" href="auth.html#service-catalog">Service Catalog</a></li> </ul> </li> </ul> </div> </nav> <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> <nav class="wy-nav-top" role="navigation" aria-label="top navigation"> <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="index.html">php-opencloud</a> </nav> <div class="wy-nav-content"> <div class="rst-content"> <div role="navigation" aria-label="breadcrumbs navigation"> <ul class="wy-breadcrumbs"> <li><a href="index.html">Docs</a> »</li> <li>Debugging</li> <li class="wy-breadcrumbs-aside"> <a href="_sources/debugging.txt" rel="nofollow"> View page source</a> </li> </ul> <hr/> </div> <div role="main"> <div class="section" id="debugging"> <h1>Debugging<a class="headerlink" href="#debugging" title="Permalink to this headline">¶</a></h1> <p>There are two important debugging strategies to use when encountering problems with HTTP transactions.</p> <div class="section" id="strategy-1-meaningful-exception-handling"> <h2>Strategy 1: Meaningful exception handling<a class="headerlink" href="#strategy-1-meaningful-exception-handling" title="Permalink to this headline">¶</a></h2> <p>If the API returns a <tt class="docutils literal"><span class="pre">4xx</span></tt> or <tt class="docutils literal"><span class="pre">5xx</span></tt> status code, it indicates that there was an error with the sent request, meaning that the transaction cannot be adequately completed.</p> <p>The Guzzle HTTP component, which forms the basis of our SDK’s transport layer, utilizes <a class="reference external" href="https://github.com/guzzle/guzzle/tree/master/src/Guzzle/Http/Exception">numerous exception classes</a> to handle this error logic.</p> <p>The two most common exception classes are:</p> <ul class="simple"> <li><tt class="docutils literal"><span class="pre">Guzzle\Http\Exception\ClientErrorResponseException</span></tt>, which is thrown when a <tt class="docutils literal"><span class="pre">4xx</span></tt> response occurs</li> <li><tt class="docutils literal"><span class="pre">Guzzle\Http\Exception\ServerErrorResponseException</span></tt>, which is thrown when a <tt class="docutils literal"><span class="pre">5xx</span></tt> response occurs</li> </ul> <p>Both of these classes extend the base <tt class="docutils literal"><span class="pre">BadResponseException</span></tt> class.</p> <p>This provides you with the granularity you need to debug and handle exceptions.</p> <div class="section" id="an-example-with-swift"> <h3>An example with Swift<a class="headerlink" href="#an-example-with-swift" title="Permalink to this headline">¶</a></h3> <p>If you’re trying to retrieve a Swift resource, such as a Data Object, and you’re not completely certain that it exists, it makes sense to wrap your call in a try/catch block:</p> <div class="highlight-php"><div class="highlight"><pre><span class="k">use</span> <span class="nx">Guzzle\Http\Exception\ClientErrorResponseException</span><span class="p">;</span> <span class="k">try</span> <span class="p">{</span> <span class="k">return</span> <span class="nv">$service</span><span class="o">-></span><span class="na">getObject</span><span class="p">(</span><span class="s1">'foo.jpg'</span><span class="p">);</span> <span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="nx">ClientErrorResponseException</span> <span class="nv">$e</span><span class="p">)</span> <span class="p">{</span> <span class="k">if</span> <span class="p">(</span><span class="nv">$e</span><span class="o">-></span><span class="na">getResponse</span><span class="p">()</span><span class="o">-></span><span class="na">getStatusCode</span><span class="p">()</span> <span class="o">==</span> <span class="mi">404</span><span class="p">)</span> <span class="p">{</span> <span class="c1">// Okay, the resource does not exist</span> <span class="k">return</span> <span class="k">false</span><span class="p">;</span> <span class="p">}</span> <span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="nx">\Exception</span> <span class="nv">$e</span><span class="p">)</span> <span class="p">{</span> <span class="c1">// Some other exception was thrown...</span> <span class="p">}</span> </pre></div> </div> <p>Both <tt class="docutils literal"><span class="pre">ClientErrorResponseException</span></tt> and <tt class="docutils literal"><span class="pre">ServerErrorResponseException</span></tt> have two methods that allow you to access the HTTP transaction:</p> <div class="highlight-php"><div class="highlight"><pre><span class="c1">// Find out the faulty request</span> <span class="nv">$request</span> <span class="o">=</span> <span class="nv">$e</span><span class="o">-></span><span class="na">getRequest</span><span class="p">();</span> <span class="c1">// Display everything by casting as string</span> <span class="k">echo</span> <span class="p">(</span><span class="nx">string</span><span class="p">)</span> <span class="nv">$request</span><span class="p">;</span> <span class="c1">// Find out the HTTP response</span> <span class="nv">$response</span> <span class="o">=</span> <span class="nv">$e</span><span class="o">-></span><span class="na">getResponse</span><span class="p">();</span> <span class="c1">// Output that too</span> <span class="k">echo</span> <span class="p">(</span><span class="nx">string</span><span class="p">)</span> <span class="nv">$response</span><span class="p">;</span> </pre></div> </div> </div> </div> <div class="section" id="strategy-2-wire-logging"> <h2>Strategy 2: Wire logging<a class="headerlink" href="#strategy-2-wire-logging" title="Permalink to this headline">¶</a></h2> <p>Guzzle provides a <a class="reference external" href="http://docs.guzzlephp.org/en/latest/plugins/log-plugin.html">Log plugin</a> that allows you to log everything over the wire, which is useful if you don’t know what’s going on.</p> <p>Here’s how you enable it:</p> <div class="section" id="install-the-plugin"> <h3>Install the plugin<a class="headerlink" href="#install-the-plugin" title="Permalink to this headline">¶</a></h3> <div class="highlight-bash"><div class="highlight"><pre>composer require guzzle/guzzle </pre></div> </div> </div> <div class="section" id="add-to-your-client"> <h3>Add to your client<a class="headerlink" href="#add-to-your-client" title="Permalink to this headline">¶</a></h3> <div class="highlight-php"><div class="highlight"><pre><span class="k">use</span> <span class="nx">Guzzle\Plugin\Log\LogPlugin</span><span class="p">;</span> <span class="nv">$client</span><span class="o">-></span><span class="na">addSubscriber</span><span class="p">(</span><span class="nx">LogPlugin</span><span class="o">::</span><span class="na">getDebugPlugin</span><span class="p">());</span> </pre></div> </div> <p>The above will add a generic logging subscriber to your client, which will output every HTTP transaction to <cite>STDOUT</cite>.</p> </div> </div> </div> </div> <footer> <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> <a href="caching-creds.html" class="btn btn-neutral float-right" title="Caching credentials"/>Next <span class="fa fa-arrow-circle-right"></span></a> <a href="services/volume/snapshots.html" class="btn btn-neutral" title="Snapshots"><span class="fa fa-arrow-circle-left"></span> Previous</a> </div> <hr/> <div role="contentinfo"> <p> © Copyright 2015, Jamie Hannaford, Shaunak Kashyap. </p> </div> <a href="https://github.com/snide/sphinx_rtd_theme">Sphinx theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a> </footer> </div> </div> </section> </div> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT:'./', VERSION:'1.12.1', COLLAPSE_INDEX:false, FILE_SUFFIX:'.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="_static/jquery.js"></script> <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <script type="text/javascript" src="_static/js/theme.js"></script> <script type="text/javascript"> jQuery(function () { SphinxRtdTheme.StickyNav.enable(); }); </script> </body> </html>