_php example of Laravel throttle middleware failure Solving method

Source: Internet
Author: User
Tags smarty template

This paper gives an example of laravel throttle middleware failure problem solving method. Share to everyone for your reference, specific as follows:

By official explanation, the access frequency limit is simple:

Route::get (' Test ', function () {return
  ' Helle World ';
}) ->middleware (' throttle ');

Also true, cache storage access times, make judgments.

Zizaco/entrust (a role-based Rights Management Pack) was used before, in which the cache_driver=file in. Env was changed to Cache_driver=array. So the problem arises. Laravel supports a variety of cache drivers, file, Array, Db, Redis, and so on, but throttle seems to work with a File type driver.

My amendment is as follows:

vendor/illuminate/cache/ratelimiter.php file

Public function __construct (Cache $cache)
{
    $this->cache = $cache;
}
Public function __construct ()
{
    $this->cache = App (' Cache ')->driver (' file ');
}

It's OK to change the above to the bottom. The throttle middleware also works.

More interested in laravel related content readers can view the site topics: "Laravel Framework Introduction and Advanced Course", "PHP Excellent Development Framework Summary", "Smarty Template Primer Tutorial", "PHP date and Time usage summary", "PHP object-oriented Program Design Introductory Course ", PHP string (String) Usage summary," PHP+MYSQL Database operation Introduction Tutorial "and" PHP common database Operation Skills Summary "

I hope this article will help you with the PHP program design based on Laravel framework.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.