简体   繁体   English

将Laravel转换为PWA

[英]Convert Laravel into PWA

I want to convert my laravel application (e-commerce store) into a progressive web application (pwa). 我想将laravel应用程序(电子商务商店)转换为渐进式Web应用程序(pwa)。 How do I do that? 我怎么做? Does it need a complete SPA in vue or it can be done using blade template engine (blade view files)? 它是否需要完整的SPA,还是可以使用刀片模板引擎(刀片视图文件)来完成? What is the proper way to do it ? 正确的做法是什么?

It really depends on what's the current state of your application, however you can start one step at the time with making your web a PWA. 这实际上取决于您的应用程序的当前状态,但是您可以将Web设置为PWA来开始一个步骤。

Couple of things you need are: 您需要做的几件事是:

  1. SSL certificate, because the service worker SSL证书,因为服务工作者

Using service worker you can hijack connections, fabricate, and filter responses. 使用服务人员,您可以劫持连接,构造和过滤响应。 Powerful stuff. 功能强大的东西。 While you would use these powers for good, a man-in-the-middle might not. 尽管您会充分利用这些能力,但中间人可能不会。 To avoid this, you can only register service workers on pages served over HTTPS, so we know the service worker the browser receives hasn't been tampered with during its journey through the network. 为了避免这种情况,您只能在通过HTTPS服务的页面上注册服务人员,因此我们知道浏览器在通过网络的过程中并未受到篡改。

Don't required on your local while you are developing stuff. 开发东西时不需要本地。

  1. A service worker you can read more about this on the link. 服务人员,您可以在链接上阅读有关此内容的更多信息。

For the service worker there a few options out there to help you getting started with different caching strategies for sections of your page. 对于服务人员,那里有一些选项可以帮助您开始使用针对页面部分的不同缓存策略。

A great example of this is: https://developers.google.com/web/tools/workbox/ 一个很好的例子是: https : //developers.google.com/web/tools/workbox/

You have a full list detailed here with the full list of things you need to cover. 您在此处有完整的清单,其中包括您需要涵盖的所有事项。

Another thing is with PWA it does not have to be all your site to work online working iteratively it's great as you can start with a simple page to show a message when you don't have connection to the internet and after that start adding more features. PWA的另一件事是,不必让您的所有站点都可以在线协同工作,这很好,因为您可以从一个简单的页面开始,在没有互联网连接时显示一条消息,然后再开始添加更多功能。

As mentioned above Google has a great list of resources for this at: 如上所述,Google在以下方面提供了大量资源:

In the context of Laravel as long as your views are rendered (blade) you can cache the responses or specific content with the service worker. 在Laravel上下文中,只要呈现(刀片)视图,您就可以将响应或特定内容与服务工作者一起缓存。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM