vladshish/cakephp-gravatar-plugin

CakePHP 2.x 的 Gravatar 插件

安装: 12

依赖者: 0

建议者: 0

安全性: 0

星星: 0

关注者: 2

分支: 3

类型:cakephp-plugin

0.0.1 2014-10-27 13:20 UTC

This package is not auto-updated.

Last update: 2024-09-24 03:40:06 UTC


README

这是一个为 CakePHP 2.0 及以上版本提供的简单 Gravatar 插件。

安装

要安装,您可以通过克隆此仓库或将它作为子模块添加到您的项目中。这两种方法都是在项目根目录下通过命令行客户端完成的。

克隆仓库

最简单的方法是克隆仓库。对应的命令是

~ git clone git@github.com:martinbean/cakephp-gravatar-plugin.git app/Plugin/Gravatar

作为子模块添加

或者,如果您已经使用 Git 进行版本控制,可以将插件作为子模块添加到项目中。为此,请运行以下命令

~ git submodule add git@github.com:martinbean/cakephp-gravatar-plugin.git app/Plugin/Gravatar
~ git submodule init

关于 Git 中子模块的更多信息,请参阅 https://git-scm.cn/book/en/Git-Tools-Submodules

使用助手

要使用助手,首先在您的 /app/Config/bootstrap.php 文件中启用插件,在底部添加以下行

CakePlugin::load('Gravatar');

或者,如果您有很多插件,可以使用以下方式

CakePlugin::loadAll();

第一步是在您的控制器中启用它

<?php
class AppController extends Controller {

    public $helpers = array(
        'Gravatar.Gravatar',
        // and any other helpers you need app-wide
    );
}

然后在视图中调用它

<?php
    echo $this->Gravatar->image('someone@example.com', array('size' => 80));
?>

您只需传递一个电子邮件地址作为第一个参数。您不需要手动进行哈希处理,因为插件会处理这一点。