php 我如何知道某个项目是用哪个 CakePHP 版本制作的?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16875569/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 11:50:10  来源:igfitidea点击:

How can I tell which CakePHP version is a project made with?

phpcakephp

提问by Mauricio Pasquier Juan

Is it posible to know the version of CakePHP used to generate a project with only the app code available?

是否有可能知道用于生成只有应用程序代码可用的项目的 CakePHP 的版本?



My problem:

我的问题:

I downloaded a project made with CakePHP, and I really can't tell wich Cake version to use. The files say, e.g. @version $Revision: 8004 $, but this is different in some files. Should I assume that the highest revision (8004) is the correct one to use?

我下载了一个用 CakePHP 制作的项目,我真的不知道要使用哪个 Cake 版本。文件说,例如@version $Revision: 8004 $,但在某些文件中这是不同的。我应该假设最高修订版 (8004) 是正确的吗?

It seems to be from around 2008, so I guess it's a 1.x version.

它似乎是从 2008 年左右开始的,所以我猜它是 1.x 版本。

PD: Hereis the code to the project.

PD:是项目的代码。

回答by Matt

I have found that the version, as of CakePHP 2.3.0, is held within a static file under the root Cake lib.

我发现从 CakePHP 2.3.0 开始,该版本保存在根 Cake 库下的静态文件中。

bash #: cat $CAKE_ROOT/lib/Cake/VERSION.txt

////////////////////////////////////////////////////////////////////////////////////////////////////
// +--------------------------------------------------------------------------------------------+ //
// CakePHP Version
//
// Holds a static string representing the current version of CakePHP
//
// CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
// Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
//
// Licensed under The MIT License
// Redistributions of files must retain the above copyright notice.
//
// @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
// @link          http://cakephp.org
// @package       cake.libs
// @since         CakePHP(tm) v 0.2.9
// @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
// +--------------------------------------------------------------------------------------------+ //
////////////////////////////////////////////////////////////////////////////////////////////////////
2.3.0

回答by Costa

Edit core.php, add to top:

编辑core.php,添加到顶部:

echo Configure::version();

回答by tarikul05

For cakephp 3.x find \vendor\cakephp\cakephp\VERSION.txt

对于 cakephp 3.x 找到 \vendor\cakephp\cakephp\VERSION.txt

enter image description here

在此处输入图片说明

////////////////////////////////////////////////////////////////////////////////////////////////////
// +--------------------------------------------------------------------------------------------+ //
// CakePHP Version
//
// Holds a static string representing the current version of CakePHP
//
// CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
// Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
//
// Licensed under The MIT License
// Redistributions of files must retain the above copyright notice.
//
// @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
// @link          http://cakephp.org
// @since         CakePHP(tm) v 0.2.9
// @license       http://www.opensource.org/licenses/mit-license.php MIT License
// +--------------------------------------------------------------------------------------------+ //
////////////////////////////////////////////////////////////////////////////////////////////////////
3.3.2

回答by Confused

Simple way :Just search for VERSION.txtfile. Open It to check the version.

简单的方法:只需搜索VERSION.txt文件。打开它以检查版本。

Path for version.txt

version.txt 的路径

For cakephp 1.*: cake/VERSION.txt

对于cakephp 1.*: cake/VERSION.txt

For cakephp 2.*: lib/Cake/ VERSION.txt

对于cakephp 2.*: lib/Cake/ VERSION.txt

For cakephp 3. & 4.*: vendor/cakephp/cakephp/ VERSION.txt

对于cakephp 3. & 4.*: vendor/cakephp/cakephp/ VERSION.txt

回答by Ravi Mane

we can check through following path

我们可以通过以下路径检查

Path=root/lib/cake/VERSION.txt

路径=root/lib/cake/VERSION.txt

Open version.txt

打开版本.txt

last line show the version of cakephp

最后一行显示 cakephp 的版本

回答by Reactgular

I'm certain this is for CakePHP 1.2.x branch, and not the CakePHP 1.3.x branch.

我确定这是用于 CakePHP 1.2.x 分支,而不是用于 CakePHP 1.3.x 分支。

You can download a 1.2.x branch from here.

您可以从这里下载 1.2.x 分支

The reason I think it's 1.2 is that all the comment headers are Copyright 2005-2008, and only the 1.2.x branch uses that date range. Everything in the 1.3.x branch is Copyright 2005-2010or newer.

我认为它是 1.2 的原因是所有评论标题都是Copyright 2005-2008,并且只有 1.2.x 分支使用该日期范围。1.3.x 分支中的所有内容都是Copyright 2005-2010或更新。

回答by Bakhtawar GIll

On the wellcome page the version is written, we dont need any command to check the version. If still it a problem, you somehow dont find the wellcome page. you can use

在wellcome页面上写了版本,我们不需要任何命令来检查版本。如果它仍然是一个问题,你不知何故找不到惠康页面。您可以使用

echo Configure::version();

回答by Mike O.O.

This is the BESTway to get it on run time

这是在运行时获取它的最佳方法

Configure::version()

3.x docs

3.x 文档

2.x docs

2.x 文档

The other way is to look for VERSION.txt

另一种方法是寻找VERSION.txt

2.x lib/Cake/VERSION.txt

2.x lib/Cake/VERSION.txt

3.x vendor/cakephp/cakephp/VERSION.txt

3.x 供应商/cakephp/cakephp/VERSION.txt

回答by Sam Rogers

In Cake 3x, inside your project directory, type bin\cake version(windows) or bin/cake version(osx/linux).

在 Cake 3x 的项目目录中,键入bin\cake version(windows) 或bin/cake version(osx/linux)。

回答by Dave

It's like not possible (without going through all the version changes, checking file/folder structures, comments...etc).

这似乎是不可能的(无需经历所有版本更改、检查文件/文件夹结构、评论...等)。

AND, it's for good reason IMO.

而且,IMO 有充分的理由。

When I start an app, I build it in the latest release. But, even by the time it goes public, I'm usually on a new release of CakePHP, and will continue to update it as they come out. My APP files don't change at all (other than the requested changes per release notes - if any). Only the cakephp/lib directory changes (and unfortunately, you don't have that).

当我启动一个应用程序时,我会在最新版本中构建它。但是,即使在它公开时,我通常也会使用 CakePHP 的新版本,并且会在它们发布时继续更新它。我的 APP 文件根本没有改变(除了每个发行说明请求的更改 - 如果有的话)。只有 cakephp/lib 目录发生了变化(不幸的是,你没有那个)。

If you're lucky, and the previous developer keeps their Cake versions in separate folders instead of overwriting, then you might find the version number in your webroot/index.phpin the CAKE_CORE_INCLUDE_PATHline, but in your case, it's not there.

如果你是幸运的,和以前的开发商维持他们的蛋糕版本在不同的文件夹,而不是覆盖,那么你可能会发现你的版本号webroot/index.phpCAKE_CORE_INCLUDE_PATH线,但在你的情况下,它不存在。

If you do have the actual Cake files (I know you don't, but other people might), then you can look in the cake/VERSION.txtfile for the version you're using.

如果您有实际的 Cake 文件(我知道您没有,但其他人可能有),那么您可以在cake/VERSION.txt文件中查找您正在使用的版本。