kitpages/util-bundle

用于 Kitpages 组件的常用小工具

安装数: 37,165

依赖者: 3

建议者: 0

安全性: 0

星标: 4

关注者: 8

分支: 2

公开问题: 0

类型:symfony-bundle

v3.0.2 2013-09-09 12:33 UTC

This package is auto-updated.

Last update: 2024-09-04 18:52:31 UTC


README

仅包含少量常用问题解决方案的方法

  • 递归创建目录
  • 发送文件到浏览器进行下载,发送图片等
  • ...

实际上我相信没有人会对其项目中的这个 Bundle 感兴趣。此 Bundle 已全局弃用。

它主要被 KitpagesCmsBundle 使用。

警告:仅在 Unix/Linux 系统上工作。

安装

如果你正在使用 DEPS

[KitpagesUtilBundle]
    git=https://github.com/kitpages/KitpagesUtilBundle.git
    target=/bundles/Kitpages/UtilBundle

Kitpages 命名空间添加到你的自动加载器

<?php // app/autoload.php

$loader->registerNamespaces(array(
    // ...
    'Kitpages' => __DIR__.'/../vendor/bundles',
));

在你的内核中启用该 Bundle

<?php // app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Kitpages\UtilBundle\KitpagesUtilBundle(),
    );
}

然后你可以使用名为 kitpages.util 的服务

用户指南

假设你在一个控制器中

<?php

$util = $this->get('kitpages.util');
// create recursively a directory
$util->mkdirr("/tmp/test/foo/bar");
// delete recursively the test directory
$util->rmdirr("/tmp/test");
// send a jpg image to the browser with a 3600 expire time
$util->getFile("/tmp/toto.jpg", 3600)