- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我目前正在开发社交应用程序。
我想在我的 PHP 后端有一个版本控制系统,但我不知道从哪里开始:我在网上查了一堆文章,但我不太明白我找到了什么。
假设我的应用程序是 v1.0。然后我创建了一个新版本 v2.0,当然我也更新了 PHP 文件。在此之后,如果有人还没有从 v1.0 更新他们的应用程序,我希望他们访问 myapp.com/v1.0/
这样应用程序就不会崩溃。
你会推荐什么?
我的一个典型的 PHP 文件如下所示,例如:
<?php
// Include files
include_once ('../../config.php');
include_once (ROOT_DIR . '/config/includes.php');
$_USERDATA = Validator::validateUser($_POST["userId"], $_POST["session"]);
// Valid session
$qry = $db->prepare('SELECT n.id, n.type, n.time, n.isRead, n.postId, n.commentId, n.text, n.inReplyToCommentId, u.id as byUserId,
( SELECT COUNT(nu.id)
FROM notificationUsers AS nu
WHERE nu.notificationId = n.id ) as detail1,
( SELECT nu2.userId
FROM notificationUsers AS nu2
WHERE nu2.notificationId = n.id ORDER BY nu2.id DESC LIMIT 1 ) as latestUserId FROM notifications AS n LEFT JOIN userData AS u ON n.byUserId = u.id
WHERE n.userId = :userId ORDER BY n.time DESC');
$qry->bindParam(':userId', $_USERDATA["userId"], PDO::PARAM_INT);
$qry->execute();
$notificationsArray = $qry->fetchAll(PDO::FETCH_ASSOC);
$returnValue = array();
$returnValue["status"] = "1";
$returnValue["title"] = "Success";
$returnValue["message"] = "Downloaded notifications";
$returnValue["data_notifications"] = $notificationsArray;
exit(json_encode($returnValue));
?>
...
所以我决定做以下事情:
像这样将每个不共享的文件放在一个文件夹中:
/api/v1.0/file.php
但是每个资源(例如图像)都在 API 之外
/resources/images/profilepictures/image.jpg
如果我做了一个小改动,我只更新 api/v1.0/
文件夹中的文件。
然后,所有使用 Application v1.1
的用户,他们正在请求 myapp.com/api/v1.1/
,但我将他们重定向到api/v1.0/我可以在其中向用户展示正确的数据(取决于请求是来自 v1.0 还是 v1.1)
如果版本加起来并且我发布了更大的更新,我将创建一个名为 v2.0
的新文件夹,然后就这样......
或者你怎么看?我应该怎么做?
最佳答案
您定义的架构是为了让您的设计面向 future ,这是良好的开端。
如果您使用像 Laravel 或 Symfony 这样的框架,您可以让您的 Models 和 Helpers 目录保持通用,同时使用 v1.x、v2.x 等子目录对 Controllers 目录进行版本控制。
如果您使用路由机制,它可以让您的生活变得轻松,例如,您的 v1.0 有 50 个 API 端点,您计划修改其中的 5 个以实现 v1.2 w/o 向后兼容性,在在这种情况下,其余 45 个 API 端点仍将与 v1.0 相同,您不想在 v1.2 目录中复制它们。
<?php
$versions = ["v1.0", "v1.2"];
route("/api/v1.0/foobar", "Controllers/v1.0/FoobarController@doSomething");
route("/api/v1.0/footar", "Controllers/v1.0/FoobarController@doTar");
route("/api/v1.2/foobar", "Controllers/v1.2/FoobarController@doSomething");
function route($endpoint, $controller)
{
// Logic to call function of a respective class/file
// and call previous version of an API if function/endpoint is not redefined in current version
}
?>
所以在上面的例子中,当客户端调用/api/v1.2/footar时,它应该为API消费者执行/api/v1.0/footar。
希望对你有帮助。
关于php - 为我的 php 应用程序(社交应用程序)创建 API 版本控制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56350079/
有没有人将 Socialize (getsocialize.com) 与 PhoneGap 集成?我正在开发一个 PhoneGap 应用程序,所以所有的 UI 都是 HTML5,但我的客户希望我们将
晚安 我试图掌握社交 SSO(Facebook/Google 等)如何在微服务架构中工作的概念。 场景 假设我有 2 个后端微服务(Order、User)和一个前端(WebApp) 用户:包含用户个人
Socialblade如何使用youtube api生成live subscriber count? 每个 channel 每秒更新一次。那会不会轻易超过速率限制? 他们从app store desc
我正在尝试在我的(maven)spring MVC secure(spring security)应用程序中配置springsocial,但是当我尝试访问/connect/或/connect/prov
我有一张 table CREATE TABLE `tbl_users` ( `user_id` int(11) NOT NULL auto_increment, `user_username`
这是当前的样本结构 Posts(Collection) - post1Id : { viewCount : 100, likes : 45,
我正在使用快速入门示例中的 Spring Social 和 Thymeleaf 进行开发,但我意识到每个 Controller 只支持一个 Facebook 对象。这意味着示例无法为多个用户提供支持,
我关注了基本的 Spring Social Facebook,它很有效。但它要求我登录浏览器。 您知道如何使用在 Spring 程序中输入的电子邮件和密码登录吗? 图表: 其他程序(发送电子邮件和密码
我想获取我关注的用户帖子列表。在conrtoller我写: @posts = Post.where(id: current_user.followers(User).map(&:id)); 在 Vie
我试图了解 ProviderSignInController 是做什么的,但我很难理解它。 因此,当我单击使用 facebook 登录时,我会转到 facebook 登录页面,然后在输入我的凭据后调用
我正在使用 Spring Boot starter social Facebook 来通过 Facebook 对用户进行身份验证/授权。 我想添加一些 Permissions ,例如 邮箱 为了检索用
我正在使用 Spring Social 通过 Facebook 或 LinkedIn 获取信息。它工作完美,我得到了我想要的,但我遇到了一个问题:它非常慢。 例如,使用 linkedin 访问我的联系
就目前情况而言,这个问题不太适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、民意调查或扩展讨论。如果您觉得这个问题可以改进并可能重新开放,visit
我们正在构建一些“sociable”单元测试(大于“单元”但明确不调用外部服务或数据库的测试)。我想知道如果 future 的开发人员编写了一个确实调用的测试,C# 中是否有一种方法可以让测试运行器抛
有什么方法可以使 Follow Us 文本与 sprite 图像内联? http://jsfiddle.net/e2ScF/66/ Follow us:
我是新来的,在互联网上看过很多这个网站和视频,现在我的 CSS fort 有问题,我会打个招呼,看看是否有人可以帮助我。我正在纠正一个网站,并在我的导航栏上有一个滑动条。但是文本 witch is h
对于那些只想切入正题并知道我在问什么的人。我的问题在下面的段落中进行了编号和加粗。 我费了好大劲想弄清楚1.)如何为 Android 社交网络应用程序实现适当的通知系统?到目前为止,我收集到的所有
我使用 spring 安全登录。现在我正在尝试添加 spring social facebook 登录,但是我得到很多错误信息。 首先,当我尝试使用与 spring social guide 相同的方
我在使用 spring-social 获取 id 和 name 以外的参数时遇到问题。 依赖关系: org.springframework.social
我正在启动 ServiceStack 社交引导 API 示例来看看它是如何工作的。 我点击了“登录”链接,但什么也没发生。我查看了代码(参见附件图片1) sign in 在“登录”链接的点击事件中,我
我是一名优秀的程序员,十分优秀!