Top 7 reasons why Laravel is better for businesses than other PHP frameworks

Laravel has become a very popular framework among software developers who design custom solutions for various businesses industries. Many IT professionals appreciate its robust features, simple and secure authentication mechanism, elegant syntax pattern, well-thought homestead, and affordable price. As of today, there are 14 versions of Laravel available. The latest one, 5.5 version, was released in August 2017. With every new version, the developers get new features which make their tasks easier. Also, the framework gets more secure, and data migration process becomes faster.

Let’s have a closer look at some Laravel advantages that make this framework an optimal choice for designing premium business software.

more at: https://medium.com/@serhii.matrunchyk/top-7-reasons-why-laravel-is-better-for-businesses-than-other-php-frameworks-c0f5e85c5b85

Laravel/Vue SPAs: How to send AJAX requests and not run into CSRF token mismatch exceptions

Creating SPAs or PWAs is very easy in VueJS. As well as creating APIs on Laravel (or Lumen). That’s why I use this pair of Vue + Laravel.

The Problem

And everything is cool until the session is expired and CSRF token is expired too. What to do in this situation? We can’t send API requests anymore because the token is expired. So we can do it either by refreshing a page automatically or asking a user to do so in some messages like “Hey, your session is expired, please click <here> to extend”. Both options are not options actually because we know that the user experience is a pretty important thing so it would be great to not to bother users with randomly refreshing pages (of course there could be some unsaved data) or showing boring messages. The other non-option could be turning off CSRF at all. Which of course is a bad practice and may lead to security pitfalls.

After hours of googling, I found lots of questions and some answers on them but no real solutions which could work for me. Here is my solution to the problem and I hope you will find it useful for your SPA project as well.

more at: https://medium.com/@serhii.matrunchyk/laravel-vue-spas-how-to-send-ajax-requests-and-not-run-into-csrf-tokens-mismatch-exceptions-da3b71b287ab

Using Laravel localization with JavaScript and VueJS

We do know that Laravel has a wonderful localization support out of box which by default is located in resources/lang folder. We can use it in PHP calling helper function like  (or you can use also __ in newer versions). Laravel’s Blade template engine also has support of this helper:

<label for="email">{{ trans('auth.email') }}</label>

or (newer versions)

<label for="email">@lang('auth.email')</label>

So the code above would be rendered as:

<label for="email">Email:</label>

Passing Laravel language strings to JavaScript

But what about JS? It has neither trans() nor __() functions by default (at least up to version 5.4). And it doesn’t even know anything about localization strings, which by the way could be organized as JSON objects in PHP (since L5.4).

more at: https://medium.com/@serhii.matrunchyk/using-laravel-localization-with-javascript-and-vuejs-23064d0c210e