GithubHelp home page GithubHelp logo

laracasts / php-vars-to-js-transformer Goto Github PK

View Code? Open in Web Editor NEW
2.2K 56.0 219.0 79 KB

Transform PHP data to JavaScript.

Home Page: https://packagist.org/packages/laracasts/utilities

License: MIT License

PHP 100.00%

php-vars-to-js-transformer's Introduction

Transform PHP Vars to JavaScript

Build Status

Often, you'll find yourself in situations, where you want to pass some server-side string/array/collection/whatever to your JavaScript. Traditionally, this can be a bit of a pain - especially as your app grows.

This package simplifies the process drastically.

Installation

Begin by installing this package through Composer.

composer require laracasts/utilities

If you use Laravel 4: instead install ~1.0 of this package (and use the documentation for that release). For Laravel 5 (or non-Laravel), ~2.0 will do the trick!

Laravel Users

For Laravel users, there is a service provider you can make use of to automatically register the necessary bindings.

Laravel 5.5+ users: this step may be skipped, as we can auto-register the package with the framework.

// config/app.php

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

When this provider is booted, you'll gain access to a helpful JavaScript facade, which you may use in your controllers.

public function index()
{
    JavaScript::put([
        'foo' => 'bar',
        'user' => User::first(),
        'age' => 29
    ]);

    return View::make('hello');
}

In Laravel 5, of course add use JavaScript; to the top of your controller.

Using the code above, you'll now be able to access foo, user, and age from your JavaScript.

console.log(foo); // bar
console.log(user); // User Obj
console.log(age); // 29

This package, by default, binds your JavaScript variables to a "footer" view, which you will include. For example:

<body>
    <h1>My Page</h1>

    @include ('footer') // <-- Variables prepended to this view
</body>

Naturally, you can change this default to a different view. See below.

Defaults

If using Laravel, there are only two configuration options that you'll need to worry about. First, publish the default configuration.

php artisan vendor:publish

// Or...

php artisan vendor:publish --provider="Laracasts\Utilities\JavaScript\JavaScriptServiceProvider"

This will add a new configuration file to: config/javascript.php.

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | View to Bind JavaScript Vars To
    |--------------------------------------------------------------------------
    |
    | Set this value to the name of the view (or partial) that
    | you want to prepend all JavaScript variables to.
    |
    */
    'bind_js_vars_to_this_view' => 'footer',

    /*
    |--------------------------------------------------------------------------
    | JavaScript Namespace
    |--------------------------------------------------------------------------
    |
    | By default, we'll add variables to the global window object. However,
    | it's recommended that you change this to some namespace - anything.
    | That way, you can access vars, like "SomeNamespace.someVariable."
    |
    */
    'js_namespace' => 'window'

];

bind_js_vars_to_this_view

You need to update this file to specify which view you want your new JavaScript variables to be prepended to. Typically, your footer is a good place for this.

If you include something like a layouts/partials/footer partial, where you store your footer and script references, then make the bind_js_vars_to_this_view key equal to that path. Behind the scenes, the Laravel implementation of this package will listen for when that view is composed, and essentially paste the JS variables within it.

js_namespace

By default, all JavaScript vars will be nested under the global window object. You'll likely want to change this. Update the js_namespace key with the name of your desired JavaScript namespace. It can be anything. Just remember: if you change this setting (which you should), then you'll access all JavaScript variables, like so:

MyNewNamespace.varName

Note

Run this artisan command after changing the view path.

php artisan config:clear

Symfony2

To use this component in Symfony2 applications you can try this bundle, built on top of PHP-Vars-To-Js-Transformer.

Without Laravel

If you're not using Laravel, then you'll need to hard-wire things yourself. (Or, feel free to submit a pull request with an implementation for your desired framework.)

First, create an implementation of the Laracasts\Utilities\JavaScript\ViewBinder interface. This class is in charge of inserting the given JavaScript into your view/page.

<?php

class MyAppViewBinder implements Laracasts\Utilities\JavaScript\ViewBinder {

    // $js will contain your JS-formatted variable initializations
    public function bind($js)
    {
        // Do what you need to do to add this JavaScript to
        // the appropriate place in your app.
    }
}

Next, put it all together:

use Laracasts\Utilities\JavaScript\Transformers\Transformer;

$binder = new MyAppViewBinder;

$javascript = new Transformer($binder, 'window'); // change window to your desired namespace

$javascript->put(['foo' => 'bar']);

Now, you can access window.foo from your JavaScript.

Remember, though, this is only necessary if you aren't using Laravel. If you are, then just reference the service provider, as demonstrated above.

License

View the license for this repo.

php-vars-to-js-transformer's People

Contributors

camaech avatar divoto avatar elrochito avatar grahamcampbell avatar gstjohn avatar holyspecter avatar jaybizzle avatar jeffreyway avatar jrean avatar laravel-shift avatar loshmis avatar marcmascarell avatar martindilling avatar mtdavidson avatar omranic avatar richardkmiller avatar spamoom avatar stayallive avatar tyloo avatar wall-e-psr avatar willvincent avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-vars-to-js-transformer's Issues

Please use window['key'] instead window.key

As it turn out, if I have key name : try-this-key

When using JavaScript::put(['try-this-key' => 'value'])

JavaScript will not understand as window.try-this-key, but it will understand window['try-this-key']

Should we change to that?

Add CDATA to print valid xml

It would be great if you add <![CDATA[ to print valid xml the same way as wp_localize_script from wordpress does

So for example it will print something like

<script type="text/javascript">/* <![CDATA[ */
var myVarName = {"ajax_url":"http:\/\/www.tutsplus.com\/wp-admin\/admin- ajax.php","nonce":"dsfsdf123r"};
/* ]]> */</script>

Trait not found

Followed the install instructions for a Laravel 5.2.39 site.

  1. composer require laracasts/utilities
  2. added Laracasts\Utilities\JavaScript\JavaScriptServiceProvider::class() to config.app providers block
  3. ran php artisan vendor:publish and verified existence of config/javascript.php
  4. added use JavaScript inside class declaration
  5. used JavaScript::put in index method of controller

when page loads it throws error Trait App\Http\Controllers\JavaScript not found.

I tried composer dump-autoload with no change, and tried using full path to library in use, same basic error, just different path.

Laravel 5: Only dot notation supported for bind_js_vars_to_this_view

Rather a warning for other users than an issue: After one of Taylor's recent commits (probably this PR here: laravel/framework@e01a6c2), the transformer now requires bind_js_vars_to_this_view setting in the config file to be dot notated. Slashs are no longer supported. If one puts e.g. 'partials/jsbody', nothing at all will happen anymore - not even an error message. Anywhere else in L5 the slash continues to work.

variable in Javascript is undefined

Hi everyone,
im using laravel 5 and angularjs for my project. And i needed to pass value from laravel to angularjs. So i installed PHP-Vars-To-Js-Transformer. it was successful. But i cannot access to Javascript variable in View:

LanguageController.php:

 public function create()
{
    $names = $this->initLang();

    JavaScript::put([
        'foo' => 'bar',
        'langs' => $names,
        'age' => 29
    ]);

    return View::make('NAATIMockTest.Admin.Language.create',compact('names'));
}

my route:

// Route create
Route::get('/Admin/Language/create', 'NAATIMockTest\LanguageController@create');

my View create.blade.php:

     <input type="text" name="search" ng-model="search">
         <select name="Name[]" multiple size="10" >
                 <option value="@{{x}}" ng-repeat="x in langs | filter:search">@{{x}}</option>
        </select><br>

javascript on create.blade.php:

var app = angular.module('myApp', []);
app.controller('langCtrl', ['$scope', '$http', function($scope, $http) {
    console.log(window.foo); // bar
    // console.log(user); // User Obj
    console.log(window.age); // 29
    console.log(window.langs);
}]);

But when i check console: there are three lines undefined. Is there anyone can help.

View::make('footer')->render();

When I use:
$html = View::make('footer')->render();
The view content is passed to the parameter ($html)

When I write this before:
JavaScript::put([
'foo' => 'Baa',
]);

this:
$html = View::make('footer')->render();

is not working properly anymore, the render() function output the data directly to the browser and not as a string to the parameter.

Its not working for Laravel 5.2 ?

Previously I was used this package in laravel 5.1 & I recently Migrated to 5.2 there I am facing problem
this package not working in 5.2 & I dont know suport is there for 5.2 or not

strange css behaviour

i've noticed visual differences before and after using JavaScript::put()

BEFORE
bildschirmfoto 2015-12-06 um 23 42 06

AFTER
bildschirmfoto 2015-12-06 um 23 44 29

Is there a simple way to fix it?

Add a license to this package.

Great stuff Jeffrey! I'd suggest you add a license to this package for legal clarification. Add a license line to the readme.md and a separate, complete one to license.md (optional) and add the license key to the composer.json.

Alias Loading in the ServiceProvider

I think it's a bad practice to load the Alias inside of the ServiceProvider because some people will want or need a different name.

Since you need to register the ServiceProvider anyways, it wouldn't be too much work adding the alias too thought.

How do you think about it? I'd love to see this and further packages (?) without this Auto-Alias-Loading :-)

Best Regards, hettiger.

Btw: Thank you for Laracasts!

Check for JsonSerializable

The Transformer should check to see whether a object implements the JsonSerializable interface. If so then the object can be safely passed along to the json_encode function later on down the line.

Inconsistencies in the encoding of collections results in some JS arrays, and some JS objects?

I'm converting the following PHP collections to JS variables:

    JavaScript::put([
        // <snip>
        'launchVideos'      => $missionObjects->where('subtype', MissionControlSubtype::LaunchVideo)->filter(function($item) {
                                    return $item->external_url != null;
                                }),
        'missionPatches'    => $missionObjects->where('subtype', MissionControlSubtype::MissionPatch),
        'pressKits'         => $missionObjects->where('subtype', MissionControlSubtype::PressKit),
        'cargoManifests'    => $missionObjects->where('subtype', MissionControlSubtype::CargoManifest),
        'pressConferences'  => $missionObjects->where('subtype', MissionControlSubtype::PressConference)->filter(function($item) {
                                    return $item->external_url != null;
                                }),
        'featuredImages'    => $missionObjects->where('subtype', MissionControlSubtype::Photo)
    ]);

Take particular note of featuredImages and missionPatches. They each have 1 member in the collection, once where'd.

Yet, the former is cast to a JS object, and the latter is cast to a JS array:

Wat

I am not doing any mutating on the front end, this is the raw output. Can anyone explain why this is occurring?

Feature Request: Multiline Output cause error (\n)

If I put a multiline Text to the view with:

\JavaScript::put(['overview', 'mutliline text with \n's ']);

then the javascript becomes corrupt (naturally, I know why).

Maybe this could be auto-escaped?

Vars are not getting bind to View

Hey Jeffrey,

for me the setting for a custom View to bind the var dose not work.

'bind_js_vars_to_this_view' => 'layouts.elements.footer'

but the vars i try to bind via JavaScript::put([ 'mydata' => 'foobar']);
is not set.
elements.footer gets included in layouts.master which extends all my Blade Files.

Laravel 5.0 Support

Jeff -

Will you be adding L5.0 support? I could use it right about now!

Thanks,
Adam.

Array posted without keys

I noticed when posting an array with unaltered keys in order: 0 => somevalue1, 1 => somevalue2 the index doesn't seemed to be posted with it, so for example it outputs: ["somevalue1", "somevalue2"]. Only, if the keys are not in order: 0 => somevalue1, 2 => somevalue2, the keys are posted with the array, like this: {"0":"somevalue1","2":" somevalue2" }. However when altering the ordered sequence of keys in the database back and forth, does change the behaviour and send the keys alongside again. Not sure what is going on, but it would be great if it would send the keys with it at all times.

window.height() becomes document.height() when inserting data

Hi!

When data is sent to the view throuhg for example:

\JavaScript::put([ 'myVar' => $data ]);

It breaks the window.height() value. The window.height() becomes the document.heithgt() value..

Does anyone know a workaround for this? Can this be fixed or is it a obvious conflict..?

Please update readme.md about service provider setting

I'm using Laravel 4.2 with composer.json

    "require": {
        "laravel/framework": "4.2.*",
        "laracasts/utilities": "~1.0",
        "laracasts/validation": "~1.0"
    },

In app/config/App.php

it works this way

'Laracasts\Utilities\UtilitiesServiceProvider',

instead

'Laracasts\Utilities\JavaScript\JavaScriptServiceProvider',

please update readme.md, Thanks ^^

Related error message, good for google search:

{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'Laracasts\\Utilities\\JavaScript\\JavaScriptServiceProvider' not found","file":"D:\\wamp\\www\\Renesas\\synergy\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\ProviderRepository.php","line":157}}

Multiple View Makes

Hello All!
I have a script that store the output of views (HTML Contents).

When trying to store multiple views contents in the same session, the library just add more JS variables to the previous variables.

It would be very nice if we can just "clear"/"clean" the previous variables.

Thanks
Asaf

php array being converted into object

if i pass

JavaScript::put([
            'foo' => 'bar',
            'age' => 29,
            'load_statuses' => $this->load_statuses, //which is an array
        ]);

its giving me object....how can i get array instead of object?

Error thrown when using using model paginate

First of, cool library.
When Laravel pagination is used, this breaks.
E.g.

return View::make('whatever', array('users' => Users::paginate(5)));

gives ErrorException: Object of class Illuminate\Pagination\Paginator could not be converted to string

Question: Loading a view using Ajax

Hi Mr Way

Please forgive me if this is not the correct platform to ask a question regarding your "PHP-Vars-To-Js-Transformer" package.

If I use the following:

$.ajax
({
    url: href,
    success: function(data)
    {
        $("#content").html(data);
    }
});

It obviously won't inject the vars when loading the partial view.

Any idea how I could go about doing this?

EDIT: I attached the vars to a footer view and the namespace is injected

I also get the following error: "Uncaught ReferenceError: injected is not defined"

middleware

is it possible to use this in a middleware to if you wanted to put the same javascript to multiple or global views?
My attempts haven't quite worked as when using it in a middleware it fails to find the class Javascript

Doesn't work with objects

$browserData = new stdClass; JavaScript::put(['browserData' => $browserData]);

Gives the following error: "The provided object needs a __toString() method". Converting the object to an array fixes this problem

Class 'Laracasts\Utilities\JavaScript\JavaScriptServiceProvider' not found

Using Laravel 4.2 here and ~1.0 of this repo. Have placed the Javascript service provider in my app.php:

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

Yet, when I run php artisan vendor:publish I get:

Class 'Laracasts\Utilities\JavaScript\JavasScriptServiceProvider' not found in H:\myproj\vendor\laravel\framework\src\Illuminate\Foundation\ProviderRepository.php on line 157

When I try and use the JavaScript facade, I get Class 'Laracasts\Utilities\JavaScript\JavaScriptServiceProvider' not found, on the same line and file as when I try and run the above command.

Also, I have tried everything by switching JavaScript to Javascript, and it didn't fix it.

Sending 0 value

Hey,

i've found a problem when sending 0 value to a variable.

Nothing is displayed so an error is trigger.

you need to add + to make javascript understanding it's a numeric.

/**
 * @param $value
 * @return mixed
 */
protected function transformNumeric($value)
{
    if (is_numeric($value))
    {
        return '+' . $value;
    }
}

+ is a javascript hack to convert string to numeric.

Javascript class not found

I get error Javascript class not found until I add use Laracasts\Utilities\JavaScript\Facades\JavaScript. I'm not using any class named javascript or added alias for that name

Call to undefined method [package]

When referencing "laravel/framework": "4.2.*" in composer.json I receive a Call to undefined method [package].

If you change the reference to "laravel/framework": "4.2.0" all works fine.

Uncaught ReferenceError: path is not defined

I have did exactly what the README says to install the library on my laravel project.
So my composer has

"laravel/framework": "~5.1",
"pingpong/modules": "dev-feature/5.1",
"cartalyst/sentinel": "~2.0",
"laracasts/utilities": "~2.0"

Then on my app.php i have the following

'providers' => [Laracasts\Utilities\JavaScript\JavaScriptServiceProvider::class]
'aliases' => ['JavaScript'=> Laracasts\Utilities\JavaScript\JavaScriptFacade::class]

So in my class i added the javascript like this use JavaScript; and then I initialized it as follows \JavaScript::put([
'path' => 'gi',
]);

but it keeps shown me "Uncaught ReferenceError: path is not defined"

Here is the way how i including the .js file from my blade template
@section('scripts')
< script src="{!! Module::asset('portfolio/portfolio.js') !!}"></ script>
@Stop

What I'm doing wrong?

Not working with redirects.

I am trying to put the authenticated user's role to access it from angular front end.
So in my AuthController

if ($this->auth->attempt(['email'=>$email, 'password' =>$password, 'status'=>'active'],$request->has('remember')))
{
    $user = $this->auth->user();
    JavaScript::put(['user' =>$user]);
    return redirect()->intended($this->redirectPath()); //doesn't work
    //But if I return view instead of a redirect as below it works
    return view('home'); //it works
}

What should I do to make it work with a redirect?

DOCTYPE issue on internet explorer

Because of the fact that the code is put on top of the html before , the browser can't detect the doctype and there becomes css issues on internet explorer 9 or below...

<!DOCTYPE html>

The javascript is displayed at the beginning of the file, so before the doctype. Is there a way to put the javascript elsewhere?

Because of this, my DOCTYPE is just ignored.

Thanks

anything other than window cuz undefined error & temp fix.

currently if we used any other namespace than window we would get
Uncaught ReferenceError: namespace_name is not defined

so to fix that we would use

// Providers/AppServiceProvider.php
public function boot()
    {
       // ...
       JavaScript::put([
            'the_var_name' => null,
            // any more vars u use
        ]);
    }

so now everything works as expected and no more errors.

Transformation for Sub-resource.

I don't know if this is included but I would like to give it a try.

Only the resource model is generated and not including the sub-resource.

$signups = Signup::with(['campaign'])->get()->toArray();

When I print_r $signups, the relationship is shown. But when I pass it to JavaScript::put the campaign object is not included.

I still have to traverse each of the sub-resource and assign it to a key.

Doesn't work with backslashes

JavaScript::put(['myPath' => '\\']);

Results in the infamous "Uncaught SyntaxError: Unexpected token ILLEGAL" JavaScript error.

Add parameter to set var _token in the JS

Hii Jeffrey,

I suggest to add a parameter if you need to create a JS var _token that is equals to Session::token(), you need it if you are doing AJAX calls.

Maybe add it too the config files to add it for default

Multiple views support ?

currently bind_js_vars_to_this_view is woking, what is the plan if i need to use this bundle for multiple views ? just curious, thanks.

Probably safer to use object-bracket notation rather than dot

I need to pass data to JS which looks like this:

window.venueEvents = window.venueEvents || {};
venueEvents.Build = {"2015-08-10":{"start":10,"end":12}};
venueEvents.Event = {"2015-08-12":{"start":10,"end":18},"2015-08-13":{"start":10,"end":18},"2015-08-14":{"start":10,"end":18},"2015-08-15":{"start":10,"end":18}};
venueEvents.De-rig = {"2015-08-15":{"start":18,"end":22},"2015-08-16":{"start":8,"end":12}};

I think it would be better to use venueEvents['De-rig'] style syntax to avoid hard-to-find issues.

(thanks for a really handy package by the way!)

No longer working with L4.3

I'm a very early 4.3 adopter whereby this [super useful!] package has seized to work for now. From what I can see in Xdebug, UtilitiesServiceProvider cannot read its two config variables anymore. For experiment, if I move the contents of the boot method at the beginning of the register method (see below), all seems fine again. Surely an unqualified fix but might point in the right direction:

class UtilitiesServiceProvider extends ServiceProvider {

    protected $defer = false;

    public function register()
    {
        $this->package('laracasts/utilities');

        AliasLoader::getInstance()->alias(
            'JavaScript',
            'Laracasts\Utilities\JavaScript\Facades\JavaScript'
        );

        $this->app->bind('JavaScript', function($app) {
            $view = Config::get('utilities::config.bind_js_vars_to_this_view');
            $namespace = Config::get('utilities::config.js_namespace');

            $binder = new LaravelViewBinder($app['events'], $view);

            return new PHPToJavaScriptTransformer($binder, $namespace);
        });
    }

    public function boot()
    {
        //
    }

    public function provides()
    {
        return ['JavaScript'];
    }

}

Some javascript shows when I run PHPUnit

After installing the package I get the following when running my PHPUnit tests:

PHPUnit 4.8.19 by Sebastian Bergmann and contributors.
.............<script>window.testScope = window.testScope || {};testScope.menuState = 'collapseAll';</script>.<script>window.testScope = window.testScope || {};testScope.menuState = 'collapseAll';</script>..<script>window.testScope = window.testScope || {};testScope.menuState = 'collapseAll';</script>..<script>window.testScope = window.testScope || {};testScope.menuState = 'collapseAll';</script>............................................... 65 / 65 (100%)

Laravel 5.1.24 (LTS) variable is undefined

I've gone through the process of setting this up multiple times but the end result is nothing each time. window.varName undefined. Other solved issues haven't worked, any help would be greatly appreciated.

Laravel Framework version 5.1.24 (LTS)

//composer.json

"require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.1.*",
    "laracasts/utilities": "^2.1"
}

//app.php

 'providers' => [
    ...
    App\Providers\RouteServiceProvider::class,
    'Laracasts\Utilities\JavaScript\JavaScriptServiceProvider',
 ]

'aliases' => [
    ...
    'View'      => Illuminate\Support\Facades\View::class,
    'JS'        => Laracasts\Utilities\JavaScript\JavaScriptFacade::class,
]

//javascript.php

return [
    'bind_js_vars_to_this_view' => 'home',
    'js_namespace' => 'window'
];


//controller

<?php

 namespace App\Http\Controllers;

 use App\Theater;
 use App\Http\Controllers\Controller;
 use Illuminate\Http\Request;
 use JavaScript;

 class NavigationController extends Controller
 {
    /* Load the home page without geolocation activated */
    public function indexWithoutGeoLocation(){
       $theaters = Theater::get();

     \JavaScript::put([
       'complexName' => 65
     ]);

  return view('home',[
    'theaters' => $theaters
  ]); 
}

my view is located at resources/views/home.blade.php and is a full view (no yields or includes) from <html> to </html>

If functionality is relevant, I'm returning a PHP instance of $theaters to render a default page, and a JS version of theaters to update the page afterwords via AJAX.

I have tried adding a facade manually by adding 'JS' => Laracasts\Utilities\JavaScript\JavaScriptFacade::class as suggested in #58 but this did nothing.

Additionally I have tried and failed to use \JavaScript::put() instead of JavaScript::put()

JavaScript Not recognized

I installed the package successfully, added 'Laracasts\Utilities\JavaScript\JavascriptServiceProvider' to the providers-array in de app.php file, but for some reason I can not use JavaScript.

I always get the error Class 'App\Http\Controllers\JavaScript' not found.
I am using Laravel 5 and PHPstorm. PHPstorm can also not find the JavaScript...

Thanks!

Class 'Laracasts\Utilities\JavaScript\JavaScriptServiceProvider' not found

I'm using a Forge provisioned server and I'm getting this error no matter what I do:

PHP Fatal error:  Class 'Laracasts\Utilities\JavaScript\JavaScriptServiceProvider' not found in /home/forge/siteurl/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 15

Checked the vendor folder, and all the files are there. Don't know what's going on. Works fine in my Homestead.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.