|
Post by account_disabled on Jan 28, 2024 5:20:36 GMT -5
本文由Rafie Younes和Wern Ancheta进行了同行评审。感谢所有 SitePoint 的同行评审者使 SitePoint 内容达到最佳状态! Pause Next Unmute Current Time 0:05 / Duration 2:00 Fullscreen 现代网络用户希望了解应用程序中发生的所有情况。您不想成为一个甚至没有通知下拉菜单的网站,不仅在所有社交媒体网站上,而且现在在其他任何地方都可以找到。 幸运的是,有了 Laravel 和Pusher,实现这个功能变得轻而易举。我们将在本教程中编写的代码可以在这里找到。 来自 Pusher 的插图,其中浏览器和移动设备与通知同步 图片来自 实时通知 为了给用户提供良好的体验,通知应该实时显示。一种方法是定期向后端发送 AJAX 请求并获取最新的通知(如果存在)。 更好的方法是利用WebSockets的强大功能,并在通知发送后立即接收通知。这就是我们将在本教程中使用的内容。 推手 Pusher 是一项网络服务 ...通过 WebSocket 将实时双向功能集成到 Web 和移动应用程序。 它有一个非常简单的 API,但我们将通过Laravel Broadcasting和Laravel Echo使其使用更加简单。 在本教程中,我们将向现有博客添加实时通知。 基本功能类似于带有 Stream 的实时 Laravel 通知。我们将从Christopher Vundi制作的这个存储库 开始(我稍微更改了它),这是一个简单的博客,用户可以在其中对帖子执行 CRUD。 该项目 初始化 首先,我们将克隆简单的 Laravel 博客然后我们将创建一个 MySQL 数据库并设置环境变量以使应 WhatsApp 号码数据 用程序能够访问该数据库。 让我们复制.env更新数据库相关变量。 现在让我们安装项目的依赖项 composer install 并运行迁移和播种命令以使用一些数据填充数据库 如果您运行该应用程序并访问,/posts您将能够看到生成的帖子列表。 检查应用程序,注册用户并创建一些帖子。这是一个非常基本的应用程序,但可以完美地为我们的演示服务。 关注用户关系 我们希望让用户能够关注其他用户,并被用户关注,因此我们必须Many To Many在用户之间创建一种关系来实现这一目标。 让我们制作一个将用户与用户相关联的数据透视表。 所有设计师都有自己的工作方式。无论您是直接在浏览器中进行设计(我的意思是使用代码),还是仅使用网络浏览器实时(或以其他方式)实时测试网页设计,都有大量供设计师使用的 Chrome 扩展,它们将使您的生活呈指数级增长更轻松。我最讨厌的事?必须打开一个巨大的桌面应用程序才能完成相对较小的任务,因此我一直在寻找能够快速解决常见设计问题的 Chrome 扩展。 Pause Next Unmute Current Time 0:07 / Duration 2:00 Fullscreen 这里有 7 个我离不开的超级有用的 Chrome 扩展,还有,这里有6 个适合设计师的优秀 Firefox 扩展, 以防你也在 Firefox 中工作(如果你是一名 Web 开发人员,你可能会在所有浏览器中进行交叉测试! )。 1.页面标尺 Page Ruler 是一个有用的 Chrome 扩展,用于查找浏览器中任何元素的位置和/或大小 - 它比使用 Chrome 代码检查器更快,或者更糟糕的是,笨拙地遍历 CSS 文件。
|
|