hshn / base64-encoded-file

提供处理base64编码文件的功能,以及symfony/form的集成

v5.0.1 2023-12-24 07:23 UTC

This package is auto-updated.

Last update: 2024-09-24 09:28:27 UTC


README

提供base64编码文件的处理功能

tests Latest Stable Version Total Downloads Latest Unstable Version License

安装

$ php composer.phar require hshn/base64-encoded-file

使用

<?php

use Hshn\Base64EncodedFile\HttpFoundation\File\Base64EncodedFile;

$file = new Base64EncodedFile(base64_encode($data));

$file->getPathname(); // "/path/to/file"
$file instanceof Symfony\Component\HttpFoundation\File\File; // true

symfony/form集成

<?php

use Hshn\Base64EncodedFile\Form\Type\Base64EncodedFileType;

$form = $formBuilder
    ->add('file', Base64EncodedFileType::class)
    ->getForm();

Symfony项目中的集成(手动安装)

在Symfony项目中使用此bundle需要以下库

  • symfony/dependency-injection
  • symfony/http-kernel
  • symfony/config

然后,您可以通过以下配置加载bundle

<?php

// bundles.php

Hshn\Base64EncodedFile\Bridge\Symfony\Bundle\Base64EncodedFileBundle::class => ['all' => true],