laracasts / PHP-Vars-To-Js-Transformer

Transform PHP data to JavaScript.
https://packagist.org/packages/laracasts/utilities
MIT License
2.21k stars 219 forks source link

Its not working for Laravel 5.2 ? #77

Closed srikanth240369 closed 7 years ago

srikanth240369 commented 8 years ago

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

SuperlativeEntity commented 8 years ago

I'm using 5.2 without any issues.

srikanth240369 commented 8 years ago

For me it is working , please refer ur empty blade in config file

'bind_js_vars_to_this_view' => 'footer'
autaut03 commented 8 years ago

same. nothing works.

autaut03 commented 8 years ago

I think author wont update this anymore. If anybody can - fork this and fix the problem.. I would do it, if I knew what's the problem.

jbcanas commented 8 years ago

Worked on my 5.2 all I did was

  1. php artisan vendor:publish
  2. edit config/javascript.php
  3. put the name of the view you want this to prepend, mine was partials.footer

'bind_js_vars_to_this_view' => 'partials.footer',

autaut03 commented 8 years ago

@jbcanas I did all this. As name of the view I put 'app' - which is my main template. NOTHING works.

jbcanas commented 8 years ago

@autaut03 do you have some kind of js console errors?

autaut03 commented 8 years ago

@jbcanas UPD: everything works fine now. I did NOTHING. wtf..

jbcanas commented 8 years ago

@autaut03 that's great ;)

ctf0 commented 8 years ago

@jbcanas am binding to layouts.app which is the main layout and getting error in console Uncaught ReferenceError: injected is not defined injected = namespace

jbcanas commented 8 years ago

@ctf0 this means injected variable is not present in your page. Does your code look like this?

Javascript::put([ 'injected' => $theCodeYouWantToSendToYourJavascript ]);

ctf0 commented 8 years ago

yeap, i think am getting the error because the item i have in the variable is temporary ?, i mean that var is only available under some condition, but if so how would i give it a default value so the error doesn't show up ?

jbcanas commented 8 years ago

It's not temporary because it's been declared globally. Can you type the injected variable in the console of your browsers dev tools and see if its there or undefined?

ctf0 commented 8 years ago

@jbcanas sorry for the late answer, just got home did what u just told me and got new error Uncaught ReferenceError: injected is not defined(…)

jbcanas commented 8 years ago

@ctf0 it seems not working on your end. You can try to chat with me on gitter https://gitter.im/jbcanas/php-to-vars?utm_source=share-link&utm_medium=link&utm_campaign=share-link

ctf0 commented 8 years ago

okay 👍

Younesi commented 8 years ago

It's not working for me too

mahfuz05 commented 8 years ago

just change 'bind_js_vars_to_this_view' => 'frontend.layouts.partials.js', 'js_namespace' => 'injected'

it will work

chanux commented 8 years ago

Remember to run php artisan vendor:publish accordingly[1]

Also the command is different for Laravel 4.2 (laracasts/utilities 1.0+).

php artisan config:publish laracasts/utilities

Check the docs in 1.0/1.0.1 branch for details.

[1] https://laravel.com/docs/5.0/packages#publishing-file-groups