Skip to main content
  1. All Posts/

clockwork

Tools PHP

Clockwork is a development tool for PHP available right in your browser. Clockwork gives you an insight into your application runtime – including request data, performance metrics, log entries, database queries, cache queries, redis commands, dispatched events, queued jobs, rendered views and more – for HTTP requests, commands, queue jobs and tests.

This repository contains the server-side component of Clockwork.

Check out on the Clockwork website for details.



<p>
  </a><br /> <a rel="nofollow noopener" target="_blank" href="https://underground.works/clockwork"></p> 
  
  <p>
    </a><br /> <a rel="nofollow noopener" target="_blank" href="https://underground.works/clockwork"></p> 
    
    <p>
      </a><br /> <a rel="nofollow noopener" target="_blank" href="https://underground.works/clockwork"></p> 
      
      <p>
        </a><br /> <a rel="nofollow noopener" target="_blank" href="https://underground.works/clockwork"></p> 
        
        <p>
          </a><br /> <a rel="nofollow noopener" target="_blank" href="https://underground.works/clockwork"></p> 
          
          <p>
            </a>
          </p>
          
          <h3 dir="auto">
            <a rel="nofollow noopener" target="_blank" id="user-content-installation" class="anchor" aria-hidden="true" href="#installation"></a>Installation
          </h3>
          
          <p>
            Install the Clockwork library via <a rel="nofollow noopener" target="_blank" href="https://getcomposer.org/">Composer</a>.
          </p>
          
          <pre class="notranslate"><code>$ composer require itsgoingd/clockwork

          <p>
            Congratulations, you are done! To enable more features like commands or queue jobs profiling, publish the configuration file via the <code>vendor:publish</code> Artisan command.<br /> <strong>Note:</strong> If you are using the Laravel route cache, you will need to refresh it using the route:cache Artisan command.<br /> Read <a rel="nofollow noopener" target="_blank" href="https://underground.works/clockwork/#docs-installation">full installation instructions</a> on the Clockwork website.
          </p>
          
          <h3 dir="auto">
            <a rel="nofollow noopener" target="_blank" id="user-content-features" class="anchor" aria-hidden="true" href="#features"></a>Features
          </h3>
          
          <h4 dir="auto">
            <a rel="nofollow noopener" target="_blank" id="user-content-collecting-data" class="anchor" aria-hidden="true" href="#collecting-data"></a>Collecting data
          </h4>
          
          <p>
            The Clockwork server-side component collects and stores data about your application.<br /> Clockwork is only active when your app is in debug mode by default. You can choose to explicitly enable or disable Clockwork, or even set Clockwork to always collect data without exposing them for further analysis.<br /> We collect a whole bunch of useful data by default, but you can enable more features or disable features you don&#8217;t need in the config file.<br /> Some features might allow for advanced options, eg. for database queries you can set a slow query threshold or enable detecting of duplicate (N+1) queries. Check out the config file to see all what Clockwork can do.<br /> There are several options that allow you to choose for which requests Clockwork is active.<br /> On-demand mode will collect data only when Clockwork app is open. You can even specify a secret to be set in the app settings to collect request. Errors only will record only requests ending with 4xx and 5xx responses. Slow only will collect only requests with responses above the set slow threshold. You can also filter the collected and recorded requests by a custom closure. CORS pre-flight requests will not be collected by default.<br /> New in Clockwork 4.1, artisan commands, queue jobs and tests can now also be collected, you need to enable this in the config file.<br /> Clockwork also collects stack traces for data like log messages or database queries. Last 10 frames of the trace are collected by default. You can change the frames limit or disable this feature in the configuration file.
          </p>
          
          <h4 dir="auto">
            <a rel="nofollow noopener" target="_blank" id="user-content-viewing-data" class="anchor" aria-hidden="true" href="#viewing-data"></a>Viewing data
          </h4>
          
          <h5 dir="auto">
            <a rel="nofollow noopener" target="_blank" id="user-content-web-interface" class="anchor" aria-hidden="true" href="#web-interface"></a>Web interface
          </h5>
          
          <p>
            Open <code>your.app/clockwork</code> to view and interact with the collected data.<br /> The app will show all executed requests, which is useful when the request is not made by browser, but for example a mobile application you are developing an API for.
          </p>
          
          <h5 dir="auto">
            <a rel="nofollow noopener" target="_blank" id="user-content-browser-extension" class="anchor" aria-hidden="true" href="#browser-extension"></a>Browser extension
          </h5>
          
          <p>
            A browser dev tools extension is also available for Chrome and Firefox:
          </p>
          
          <ul dir="auto">
            <li>
              <a rel="nofollow noopener" target="_blank" href="https://chrome.google.com/webstore/detail/clockwork/dmggabnehkmmfmdffgajcflpdjlnoemp">Chrome Web Store</a>
            </li>
            <li>
              <a rel="nofollow noopener" target="_blank" href="https://addons.mozilla.org/en-US/firefox/addon/clockwork-dev-tools/">Firefox Addons</a>
            </li>
          </ul>
          
          <h5 dir="auto">
            <a rel="nofollow noopener" target="_blank" id="user-content-toolbar" class="anchor" aria-hidden="true" href="#toolbar"></a>Toolbar
          </h5>
          
          <p>
            Clockwork now gives you an option to show basic request information in the form of a toolbar in your app.<br /> The toolbar is fully rendered client-side and requires installing a tiny javascript library.<br /> <a rel="nofollow noopener" target="_blank" href="https://underground.works/clockwork/#docs-viewing-data">Learn more</a> on the Clockwork website.
          </p>
          
          <h4 dir="auto">
            <a rel="nofollow noopener" target="_blank" id="user-content-logging" class="anchor" aria-hidden="true" href="#logging"></a>Logging
          </h4>
          
          <p>
            You can log any variable via the clock() helper, from a simple string to an array or object, even multiple values:
          </p>
          
          <pre>clock(User::first(), auth()-&gt;user(), $username)</pre>
          
          <p>
            The <code>clock()</code> helper function returns it&#8217;s first argument, so you can easily add inline debugging statements to your code:
          </p>
          
          <pre>User::create(clock($request-&gt;all()))</pre>
          
          <p>
            If you want to specify a log level, you can use the long-form call:
          </p>
          
          <pre>clock()-&gt;info("User {$username} logged in!")</pre>
          
          <h4 dir="auto">
            <a rel="nofollow noopener" target="_blank" id="user-content-timeline" class="anchor" aria-hidden="true" href="#timeline"></a>Timeline
          </h4>
          
          <p>
            Timeline gives you a visual representation of your application runtime.<br /> To add an event to the timeline &#8211; start it with a description, execute the tracked code and finish the event. A fluent api is available to further configure the event.
          </p>
          
          <pre>// using timeline api with begin/end and fluent configuration

clock()->event(‘Importing tweets’)->color(‘purple’)->begin(); … clock()->event(‘Importing tweets’)->end();

          <p>
            Alternatively you can execute the tracked code block as a closure. You can also choose to use an array based configuration instead of the fluent api.
          </p>
          
          <pre>// using timeline api with run and array-based configuration

clock()->event(‘Updating cache’, [ ‘color’ => ‘green’ ])->run(function () { … });

          <p>
            Read more about available features on the <a rel="nofollow noopener" target="_blank" href="https://underground.works/clockwork">Clockwork website</a>.
          </p>
          
          <p>
            <a rel="nofollow noopener" target="_blank" href="https://underground.works"></p> 
            
            <p>
              </a>
            </p>