简体   繁体   English

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

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

Is it possible 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 which Cake version to use.我下载了一个用 CakePHP 制作的项目,我真的不知道该使用哪个 Cake 版本。 The files say, eg @version $Revision: 8004 $ , but this is different in some files.文件说,例如@version $Revision: 8004 $ ,但这在某些文件中是不同的。 Should I assume that the highest revision (8004) is the correct one to use?我应该假设最高修订版 (8004) 是正确的吗?

It seems to be from around 2008, so I guess it's a 1.x version.它似乎是从 2008 年左右开始的,所以我猜它是 1.x 版本。

PD: Here is the code to the project. PD: 是项目的代码。

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

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

echo Configure::version();

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

在此处输入图片说明

////////////////////////////////////////////////////////////////////////////////////////////////////
// +--------------------------------------------------------------------------------------------+ //
// 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

Simple way : Just search for VERSION.txt file.简单的方法:只需搜索VERSION.txt文件。 Open It to check the version.打开它以检查版本。

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

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.我认为它是 1.2 的原因是所有评论标题都是Copyright 2005-2008 ,并且只有 1.2.x 分支使用该日期范围。 Everything in the 1.3.x branch is Copyright 2005-2010 or newer. 1.3.x 分支中的所有内容Copyright 2005-2010或更新版本。

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 的版本

On the wellcome page the version is written, we dont need any command to check the version.在wellcome页面上写了版本,我们不需要任何命令来检查版本。 If still it a problem, you somehow dont find the wellcome page.如果它仍然是一个问题,你不知何故找不到惠康页面。 you can use您可以使用

echo Configure::version();

This is the BEST way 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

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.但是,即使在它公开时,我通常也会使用 CakePHP 的新版本,并且会在它们发布时继续更新它。 My APP files don't change at all (other than the requested changes per release notes - if any).我的 APP 文件根本没有改变(除了每个发行说明请求的更改 - 如果有的话)。 Only the cakephp/lib directory changes (and unfortunately, you don't have that).只有 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.php in the CAKE_CORE_INCLUDE_PATH line, but in your case, it's not there.如果您很幸运,并且之前的开发人员将他们的 Cake 版本保存在单独的文件夹中而不是覆盖,那么您可能会在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.txt file for the version you're using.如果您有实际的 Cake 文件(我知道您没有,但其他人可能有),那么您可以在cake/VERSION.txt文件中查看您正在使用的版本。

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

Also for Linux console you can check your CakePHP version like this.同样对于 Linux 控制台,您可以像这样检查您的 CakePHP 版本。
Change example.com with your domain name.使用您的域名更改 example.com。

# grep ^[^\/] /var/www/vhosts/example.com/httpdocs/lib/Cake/VERSION.txt

在应用根目录下的 cake 3.0 >>> cat vendor/cakephp/cakephp/VERSION.txt

For Cakephp3, open command line and go to your Project App directory and type bin/cake ,it will show you something like this *对于 Cakephp3,打开命令行并转到您的 Project App 目录并输入bin/cake ,它会显示如下内容 *

Welcome to CakePHP v3.3.5 Console欢迎使用 CakePHP v3.3.5 控制台

Which is your current cakephp Version.这是您当前的cakephp 版本。

Any PHP Framework using composer having version details in composer.json file任何使用composer PHP 框架在composer.json文件中具有版本详细信息

在此处输入图片说明

Example例子

{
    "name": "cakephp/app",
    "description": "CakePHP skeleton app",
    "homepage": "http://cakephp.org",
    "type": "project",
    "license": "MIT",
    "require": {
        "php": ">=5.4.16",
        "cakephp/cakephp": "3.6.11",//<<< Cakephp Version
        "mobiledetect/mobiledetectlib": "2.8.33",
        "cakephp/migrations": "1.8.1",
        "cakephp/plugin-installer": "*",
        "donatj/simplecalendar": "^0.6.1",
        "davidyell/proffer": "0.6.3"
    },

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

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