1

I'm new to Laravel 5 and I was trying to set up PHP-Vars-To-Js-Transformer .The problem is, that I'm unable to use JavaScript facade in my controller. This class is not found.

My Controller:

<?php namespace App\Http\Controllers;

class HomeController extends Controller
{



public function __construct()
{
    $this->middleware('auth');
}

public function index()
{
    $ch = curl_init();
    // Disable SSL verification
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    .....
    return view('home',compact('decodedJSON','encodedMainArray'));
}

  }

My // app/config/app.php

'providers' => [
'...',
'Laracasts\Utilities\JavaScript\JavascriptServiceProvider'
];

I've also run commands php artisan vendor:publish and composer install. I don't know, if I'm missing something special.. Thanks

Community
  • 1
  • 1
user2151486
  • 778
  • 2
  • 13
  • 25

3 Answers3

1

I've figured it out. The problem was in namespacing. The solution was to add use Laracasts\Utilities\JavaScript\JavaScriptFacade as JavaScript; at the beginning of the controller file.

user2151486
  • 778
  • 2
  • 13
  • 25
0

To use the facasde like that, add it to your aliases in config/app.php:

'JavaScript' => 'Laracasts\Utilities\JavaScript\JavaScriptFacade'
Joseph Silber
  • 214,931
  • 59
  • 362
  • 292
  • 1
    Thank You, but this didn't work. Laravel is still unable to recognize this class. Even PhPStorm says "Undefined class JavaScript" – user2151486 May 22 '15 at 08:36
0

Use these lines at the beginning of the controller. I found this

use Laracasts\Utilities\JavaScript\JavaScriptFacade; use JavaScript;

DPS
  • 943
  • 11
  • 22