承接 mirko-pagliai/cakephp-essentials 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mirko-pagliai/cakephp-essentials

最新稳定版本:1.0.14

Composer 安装命令:

composer require mirko-pagliai/cakephp-essentials

包简介

cakephp-essentials

README 文档

README

Software License CI codecov Codacy Badge

Various classes and utilities useful for various CakePHP projects.

Creates links to assets

In your composer.json, add the post-update-cmd command event:

  "scripts": {
    "post-update-cmd": [
        "rm -rf webroot/vendor/ && mkdir webroot/vendor/ -p",
        "ln -s ../../vendor/twbs/bootstrap/dist/ webroot/vendor/bootstrap -f",
        "ln -s ../../vendor/twbs/bootstrap-icons/font/ webroot/vendor/bootstrap-icons -f",
        "ln -s ../../vendor/axllent/jquery/ webroot/vendor/jquery -f",
    ]
  },

See Composer documentation.

Or run the commands directly in the shell:

rm -rf webroot/vendor/ && mkdir webroot/vendor/ -p
ln -s ../../vendor/twbs/bootstrap/dist/ webroot/vendor/bootstrap -f
ln -s ../../vendor/twbs/bootstrap-icons/font/ webroot/vendor/bootstrap-icons -f
ln -s ../../vendor/axllent/jquery/ webroot/vendor/jquery -f

It can also be useful to launch the command:

bin/cake plugin assets symlink -q --overwrite

Extends the View

use Cake\Essentials\View\View;

class AppView extends View
{
}

If necessary, you can rewrite the default helpers by implementing the initialize() method and calling parent::initialize() before adding your own helpers.

class AppView extends View
    public function initialize(): void
    {
        parent::initialize();
    
        /**
         * These override any helpers defined by the parent.
         */
        $this->addHelper('Html');
        $this->addHelper('Form');
    }
}

Add some basic assets to the layout

You can consider adding some key assets to your layout, depending on your needs:

Css:

echo $this->fetch('css');
echo $this->Html->css('/vendor/bootstrap/css/bootstrap.min.css');
echo $this->Html->css('/vendor/bootstrap-icons/bootstrap-icons.min.css');

Scripts:

echo $this->fetch('script');
echo $this->Html->script('/vendor/jquery/jquery.min.js');
echo $this->Html->script('/vendor/bootstrap/js/bootstrap.min.js');
echo $this->Html->script('/cake/essentials/js/collapsible-toggle-icon.min.js');

Using Tooltips and Popovers

Several helper methods support tooltips and popovers and can generate them automatically.

Please refer to the Bootstrap documentation before using them (here and here).

Keep in mind that:

  1. both depend on the third-party library Popper, which you need to include, or you can use bootstrap.bundle.min.js which contains Popper;
  2. you will need to initialize both, as indicated in the documentation.
    You can include webroot/js/enable-popovers.min.js and webroot/js/enable-tooltips.min.js files in yourt layout, which will do it automatically:
echo $this->Html->script('/cake/essentials/js/enable-popovers.min.js');
echo $this->Html->script('/cake/essentials/js/enable-tooltips.min.js');

How to use Bake templates

In your config/bootstrap.php file:

Configure::write('Bake.theme', 'Cake/Essentials');

Or you can use the --theme option (or --t) with Cake/Essentials value.
Example:

bin/cake bake template ServiceStops -t Cake/Essentials -f

See also CakePHP Bake 2.x Cookbook.

Sets the default locale date and time format

For example, in your bootstrap.php:

/**
 * Sets the default locale date and time format.
 *
 * @see https://book.cakephp.org/5/en/core-libraries/time.html#setting-the-default-locale-and-format-string
 * @see https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax
 */
Date::setToStringFormat('dd/MM/yyyy');
DateTime::setToStringFormat('dd/MM/yyyy HH:mm');

统计信息

  • 总下载量: 3.94k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-30