Question

I'm making web app using Laravel and AngularJS. To prevent CSRF, I added following script to index.php file.

<script>
angular.module("contactApp").constant("CSRF_TOKEN", '<?php echo csrf_token(); ?>');
</script>

But it shows the following Fatal error.

"Call to undefined function csrf_token()"

In Laravel setting, I changed the View Storage Paths in view.php to public_html folder. It seems it makes the error. How I can solve this problem with using an alternative View Storage Paths?

Was it helpful?

Solution

Probably you have a wrong value in you're view path?

// view.php
'paths' => array(__DIR__.'/../../public'),

OTHER TIPS

To get a CSRF token in Laravel the code is:

<?php echo Form::token(); ?>

or if your using Blade templates:

{{ Form::token() }}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top