title: List all registered variables inside a Laravel view
body: <p>I am using Laravel 5. I would like to know which are all variables passed to a view inside the view itself.</p>
  
  <p>Since all variables are in the view scope I thought I could use the generic PHP function: <code>get_defined_vars();</code> <a href="http://php.net/manual/en/function.get-defined-vars.php">http://php.net/manual/en/function.get-defined-vars.php</a></p>
  
  <p>Something like this:</p>
  
  <pre><code>  // resources/view/home.blade.php
    &lt;html&gt;
    &lt;body&gt;
         &lt;?php print_r(get_defined_vars()); ?&gt;
    &lt;/body&gt;
    &lt;/html&gt;
  </code></pre>
  
  <p>But I would like to know if there is a better way (something like <code>View::getData()</code>)</p>
  
  <p><strong>Note:</strong> get_defined_vars() deosn't work becausee it returns hundreds of useless variables (Laravel components)</p>
  
  <p>This is a snippet (partial) using <code>print_r(get_defined_vars())</code> (i think it goes in infinite recursion loop):</p>
  
  <pre><code>      Array
  (
      [__path] =&gt; C:\net\laravel\storage\framework\views/8e030a77b0bdbacc2c4182fc04420d1d
      [__data] =&gt; Array
          (
              [__env] =&gt; Illuminate\View\Factory Object
                  (
                      [engines:protected] =&gt; Illuminate\View\Engines\EngineResolver Object
                          (
                              [resolvers:protected] =&gt; Array
                                  (
                                      [php] =&gt; Closure Object
                                          (
                                              [this] =&gt; Illuminate\View\ViewServiceProvider Object
                                                  (
                                                      [app:protected] =&gt; Illuminate\Foundation\Application Object
                                                          (
                                                              [basePath:protected] =&gt; C:\net\laravel
                                                              [hasBeenBootstrapped:protected] =&gt; 1
                                                              [booted:protected] =&gt; 1
                                                              [bootingCallbacks:protected] =&gt; Array
                                                                  (
                                                                      [0] =&gt; Closure Object
                                                                          (
                                                                              [static] =&gt; Array
                                                                                  (
                                                                                      [instance] =&gt; Illuminate\Bus\BusServiceProvider Object
                                                                                          (
                                                                                              [defer:protected] =&gt; 1
                                                                                              [app:protected] =&gt; Illuminate\Foundation\Application Object
   *RECURSION*
                                                                                          )
  
                                                                                  )
  
                                                                              [this] =&gt; Illuminate\Foundation\Application Object
   *RECURSION*
                                                                          )
  
                                                                      [1] =&gt; Closure Object
                                                                          (
                                                                              [static] =&gt; Array
                                                                                  (
                                                                                      [instance] =&gt; Illuminate\Translation\TranslationServiceProvider Object
                                                                                          (
                                                                                              [defer:protected] =&gt; 1
                                                                                              [app:protected] =&gt; Illuminate\Foundation\Application Object
   *RECURSION*
                                                                                          )
  
                                                                                  )
  
                                                                              [this] =&gt; Illuminate\Foundation\Application Object
   *RECURSION*
                                                                          )
  
                                                                  )
  
                                                              [bootedCallbacks:protected] =&gt; Array
                                                                  (
                                                                  )
  
                                                              [terminatingCallbacks:protected] =&gt; Array
                                                                  (
                                                                  )
  
                                                              [serviceProviders:protected] =&gt; Array
                                                                  (
                                                                      [0] =&gt; Illuminate\Events\EventServiceProvider Object
                                                                          (
                                                                              [app:protected] =&gt; Illuminate\Foundation\Application Object
   *RECURSION*
                                                                              [defer:protected] =&gt; 
                                                                          )
  </code></pre>